Skip to content

feat: more components are generic#2743

Merged
metonym merged 6 commits intomasterfrom
metonym/more-generics2
Mar 9, 2026
Merged

feat: more components are generic#2743
metonym merged 6 commits intomasterfrom
metonym/more-generics2

Conversation

@metonym
Copy link
Collaborator

@metonym metonym commented Mar 9, 2026

Value-like and data-like props on several components were previously typed as any. This PR adds generic type parameters (defaulting to any) so consumers can get type-safe bindings and event payloads when they specify a type, while remaining backwards-compatible.

Example

<script lang="ts">
  import { LocalStorage } from "carbon-components-svelte";
  type Theme = "light" | "dark" | "auto";
  let theme: Theme = "light";
</script>

<LocalStorage key="theme" bind:value={theme} />
<!-- theme and update event detail are now Theme, not any -->
Screenshot 2026-03-08 at 7 05 31 PM

@metonym metonym merged commit dbfe108 into master Mar 9, 2026
10 checks passed
@metonym metonym deleted the metonym/more-generics2 branch March 9, 2026 02:09
@metonym metonym mentioned this pull request Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant