Skip to content

Type helper: PropsWithChildrenΒ #15706

@Hugos68

Description

@Hugos68

Describe the problem

I often catch myself creating the same helper in nearly every Svelte project:

interface PropsWithChildren<T extends []> {
  children?: Snippet<T>;
}

And using it like this:

interface Props extends PropsWithChildren {
    ....
}

const props: Props = $props();

Typing the same code over and over is a waste of time.

Describe the proposed solution

Svelte could export this helper as a first party type utility.

React, although not known to have done everything best, does have this utility and I use it whenever I have any React project

Importance

nice to have

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions