Skip to content

Add helper types to extract props a component accepts #7584

Closed
@dummdidumm

Description

@dummdidumm

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions