Skip to content

Support TypeScript generics for more componentsΒ #2285

@metonym

Description

@metonym

#1954 added generics support to DataTable, which greatly enhances DX.

A similar experience should be applied to other components. This would allow passing arbitrary data without additional typing. Functionally, this should be backwards-compatible.

This applies to the items prop for:

  • ComboBox
  • Dropdown
  • MultiSelect

This enables object properties to be automatically inferred.

<script lang="ts">
  export let items = [
    { id: "0", text: "Slack", price: 100 },
    { id: "1", text: "Email", price: 200 },
    { id: "2", text: "Fax", price: 300 },
  ];
</script>

<ComboBox {items} let:item>
  Item {item.price}
</ComboBox>

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesttypescriptTypeScript-related pain point

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions