Replies: 2 comments
-
If I declare The workaround which I found is to explicitly type cast the component to the correct concrete type:
This works, but is quite cumbersome, since I have to create this cast anytime I want to use the component without errors. It would be great if Svelte could support type inference by use, like normal generic types and functions do. Here is a Playground sample with the working work around: |
Beta Was this translation helpful? Give feedback.
-
Would recommend opening an actual issue in |
Beta Was this translation helpful? Give feedback.
-
Hi,
we are working i a strictly typed JS + JSDoc environment. It is great that we can write type-safe props with
@type
and have full type-checking everywhere. We can also use generic functions and types with JSDoc@template {...} T
But it seems that using a generic Svelte component
generics="T extends"
is only possible with TypeScript?Is there any trick or any plan to support generic components with JSDoc?
We have a generic table component and it would be great if we could automatic type-safety in our snippets for the columns if we define the component with a generic row type, which would then be inferred by the passed array-type.
Beta Was this translation helpful? Give feedback.
All reactions