mirror of https://github.com/sveltejs/svelte
fix: add bigint to Primitive type for $state.snapshot (#18388)
Fixes #18385 ## Problem `$state.snapshot` infers BigInt properties as `never` because `bigint` is missing from the `Primitive` type definition. BigInt is a valid JavaScript primitive and is supported by `structuredClone`. ## Solution Added `bigint` to the `Primitive` type in both `packages/svelte/src/ambient.d.ts` and `packages/svelte/types/index.d.ts`. ## Before ```ts const object = $state({ number: 1n }); const snapshot = $state.snapshot(object); // snapshot.number is inferred as never ❌ After const object = $state({ number: 1n }); const snapshot = $state.snapshot(object); // snapshot.number is correctly inferred as bigint ✅ Tests and linting - [x] This is a type-only change, no runtime behavior affected --------- Co-authored-by: Rich Harris <hello@rich-harris.dev>pull/18389/head
parent
51baf1c1af
commit
3d83c9abe6
@ -0,0 +1,5 @@
|
||||
---
|
||||
"svelte": patch
|
||||
---
|
||||
|
||||
fix: type BigInts in `$state.snapshot(...)` return values
|
||||
Loading…
Reference in new issue