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
If I have a Parent.svelte component that has a children prop, passing children to the component implicitly (without the {#snippet children()} block) I get the error Property 'children' is missing in type '{}' but required in type '{ children: () => void; }'.
If I put the children inside a {#snippet children()} block then the error goes away
Reproduction
REPL (Error won't show up in the REPL, you may need to copy it over to VS Code)
Expected behaviour
Implicit children get detected correctly
System Info
OS: MacOS
IDE: VSCode
Which package is the issue about?
No response
Additional Information, eg. Screenshots
Not directly related to the bug, but I'm wondering if Svelte is going to provide some sort of Snippet type helper. For the time being, I'm using this:
It's not really shorter than just writing out the actual function type, but it makes it more obvious which props are snippets and which aren't when typing $props
The text was updated successfully, but these errors were encountered:
A snippet helper will be added in the next release, and language tools will error if you don't use it to type the snippet props (at the @render location) sveltejs/svelte#9584
@dummdidumm That's great! I didn't realize until now that snippets can't take more than one argument. Looks like my type helper was a little over-engineered 😅
- pass children to zero types Svelte 5: +layout.svelte children not included in zero-effort type safety #2212
- add possibility to pass in version to svelte2tsx to differentiate transpiler targets
- add implicit children prop in Svelte 5 mode Svelte 5: Implicit children not detected correctly #2211
- add best-effort fallback typings to $props() rune
- hide deprecation warnings in generated code Svelte 5: Typescript generics in components are marked as deprecated svelte#9586
Describe the bug
If I have a
Parent.svelte
component that has achildren
prop, passing children to the component implicitly (without the{#snippet children()}
block) I get the errorProperty 'children' is missing in type '{}' but required in type '{ children: () => void; }'.
If I put the children inside a
{#snippet children()}
block then the error goes awayReproduction
REPL (Error won't show up in the REPL, you may need to copy it over to VS Code)
Expected behaviour
Implicit children get detected correctly
System Info
Which package is the issue about?
No response
Additional Information, eg. Screenshots
Not directly related to the bug, but I'm wondering if Svelte is going to provide some sort of
Snippet
type helper. For the time being, I'm using this:It's not really shorter than just writing out the actual function type, but it makes it more obvious which props are snippets and which aren't when typing
$props
The text was updated successfully, but these errors were encountered: