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
sveltejs/language-tools#442 (comment) and a similar post above in that thread shows that people want to have a way to get the prop a component expects from its definition. This requires internal knowledge of the class interface which is brittle and might break for people (it's not regarded as public API). We therefore should add a convenience type that does this for us.
Describe the proposed solution
type ComponentProps<T> = T extends new (...args: any[]) => SvelteComponentTyped<infer Props> ? Props : unknown // or never, or any?
Alternatives considered
none
Importance
would make my life easier
The text was updated successfully, but these errors were encountered:
ComponentType eases typing "this is a variable that expects a Svelte component constructor (of a certain shape)". Removes the need for SvelteComponentTyped to be an extra type so it can be deprecated in v4 and removed in v5, and SvelteComponent(Dev) can receive the same generic typings as SvelteComponetTyped in v4.
ComponentProps eases typing "give me the props this component expects". Closes#7584
Co-authored-by: Simon Holthausen <[email protected]>
Co-authored-by: Hofer Ivan <[email protected]>
Co-authored-by: Ignatius Bagus <[email protected]>
Describe the problem
sveltejs/language-tools#442 (comment) and a similar post above in that thread shows that people want to have a way to get the prop a component expects from its definition. This requires internal knowledge of the class interface which is brittle and might break for people (it's not regarded as public API). We therefore should add a convenience type that does this for us.
Describe the proposed solution
type ComponentProps<T> = T extends new (...args: any[]) => SvelteComponentTyped<infer Props> ? Props : unknown // or never, or any?
Alternatives considered
none
Importance
would make my life easier
The text was updated successfully, but these errors were encountered: