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 just found out that if you create a {#snippet} in your component, you can reference it from the script tag:
<script>
console.log(mySnippet) // Shows type error, but works fine
</script>
{#snippetmySnippet()}
...
{/snippet}
Not sure if this is a bug, or if this is actually ok behavior and the type checker just marks it as an error since the snippet function isn't declared inside the script tag. I do see this as potentially useful, though, if you wanted to pass a snippet around through a store or context (see REPL). And in that case, the fix could probably just be to make intellisense aware of snippets inside the script tag.
This actually looks and works fine in the REPL. If you have this same code in VS Code though, it will highlight mySnippet as an error inside setContext
Describe the bug
I just found out that if you create a
{#snippet}
in your component, you can reference it from the script tag:Not sure if this is a bug, or if this is actually ok behavior and the type checker just marks it as an error since the snippet function isn't declared inside the script tag. I do see this as potentially useful, though, if you wanted to pass a snippet around through a store or context (see REPL). And in that case, the fix could probably just be to make intellisense aware of snippets inside the script tag.
Reproduction
REPL
This actually looks and works fine in the REPL. If you have this same code in VS Code though, it will highlight
mySnippet
as an error insidesetContext
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: