You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am pretty sure this is not necessarily a bug but an intended behaviour. However, the error given is so vague, and I could not find any documentation explaining why this functionality is not supported. Given is the following snippet:
<scriptlang="ts">
importtype { Snippet } from'svelte';function formatter(v:number):ReturnType<Snippet<[number, string]>> {returndraw(v, 'pink'); }
</script>
{@renderdraw(0, 'orange')}
{@renderformatter(0)} <!-- ERROR: Value is not a function error-->
{#snippetdraw(value: number, color: string)}
<p>
value:
<spanstyle="background:{color}">
{value}
</span>
</p>
{/snippet}
I try to create a new snippet that only takes part of an original snippet. Type wise this should be supported as draw has the following typing:
The browser complains with a strange error which I have never encountered before. I suspect it has something to do with component mounting, unmounting or scoping? What part of Svelte magic am I missing in order to understand this error? Would this behaviour be possible with createRawSnippet?
You get odd errors because the actual shape of the function is different from the one reported by the generated types. The types show the signature used in @render, the actual function also expects an $$anchor argument that the snippet is rendered to.
Thanks for guiding me in the right direction. The comment by @Ocean-OS was very helpful. I have updated the REPL here. However, I still have some trouble defining narrower types for the formatter function instead of using type any.
Describe the bug
I am pretty sure this is not necessarily a bug but an intended behaviour. However, the error given is so vague, and I could not find any documentation explaining why this functionality is not supported. Given is the following snippet:
I try to create a new snippet that only takes part of an original snippet. Type wise this should be supported as
draw
has the following typing:My expectation was that
formatter
would behave similarly to the followingThe browser complains with a strange error which I have never encountered before. I suspect it has something to do with component mounting, unmounting or scoping? What part of Svelte magic am I missing in order to understand this error? Would this behaviour be possible with createRawSnippet?
Reproduction
https://svelte.dev/playground/33470f759ec0434cbcb597f5119a36da?version=5.2.11
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: