-
-
Notifications
You must be signed in to change notification settings - Fork 223
Description
Describe the bug
Snippets declared at the top level of a .svelte file can be exported from a <script module> for use in other components, provided they don’t reference any declarations in a non-module <script> (whether directly or indirectly, via other snippets) (demo):
<script module> export { add }; </script> {#snippet add(a, b)} {a} + {b} = {a + b} {/snippet}This requires Svelte 5.5.0 or newer
Reproduction
when i try that, i get a type error
Type '(props: ScatterHandlerProps) => ReturnType<import("svelte").Snippet>' is not assignable to type 'Snippet<[ScatterHandlerProps<Record<string, unknown>>]>'.
Type '{ '{@render ...} must be called with a Snippet': "import type { Snippet } from 'svelte'"; } & typeof SnippetReturn' is not assignable to type '{ '{@render ...} must be called with a Snippet': "import type { Snippet } from 'svelte'"; } & typeof SnippetReturn'. Two different types with this name exist, but they are unrelated.
Expected behaviour
same type should be inferred for snippet in external importing Svelte components as in the original component that defines the snippet where no type error is raised when using the snippet in the same way
System Info
- OS: macOS
- IDE: Cursor
Which package is the issue about?
svelte-check
Additional Information, eg. Screenshots
No response