Skip to content

Introduce $typed() rune, complimentary to $bindable() #14844

Open
@angryziber

Description

@angryziber

Describe the problem

As explained in #14810 and #9241, using $props rune is inconvenient with TypeScript.

Describe the proposed solution

There is already a typed $bindable rune that can be used for inline types. We could introduce a $typed (non-bindable) rune to be able to specify fallback value and type at the declaration site of the prop, not separately:

let {
  size = $typed<'sm' | 'md' | 'lg'>('md'), // optional
  color = $typed<Color>(), // required
  value = $bindable<string>()
} = $props()

instead of

let {
  size = 'md',
  color,
  value = $bindable()
}: {
  size?: 'sm' | 'md' | 'lg',
  color: Color,
  value: string
} = $props()

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