-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add helper types to extract props a component accepts #7584
Labels
Comments
dummdidumm
pushed a commit
to dummdidumm/svelte
that referenced
this issue
Jun 28, 2022
5 tasks
dummdidumm
added a commit
that referenced
this issue
Jul 1, 2022
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 <simon.holthausen@accso.de> Co-authored-by: Hofer Ivan <ivan.hofer@outlook.com> Co-authored-by: Ignatius Bagus <ignatius.mbs@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: