Skip to content

Why $props is any By Default #14730

@rchavezj

Description

@rchavezj

Describe the problem

Lack of Type Information: $props doesn't inherently know what types the props should have unless explicitly specified.

Dynamic Nature of Props: Svelte allows any type of data to be passed as props, so without explicit definitions, TypeScript defaults to any.

Loose Typing in $props: $props is a generic utility, and its type must be explicitly constrained with a type parameter ($props<Type>()).

By following one of the options above, you can enforce strict typing and eliminate the any types in your $props.

anyDislike

Describe the proposed solution

Hovering over the variables would not have :any but the explicit type we passed into the prop.

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