fix: add bigint to Primitive type for $state.snapshot#18388
Conversation
BigInt is a valid JavaScript primitive and is supported by structuredClone. Adding it to the Primitive type ensures that .snapshot correctly infers BigInt properties instead of resolving to never. Fixes sveltejs#18385
🦋 Changeset detectedLatest commit: 42ba325 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This is a type-only change that doesn't affect runtime behavior. No changeset needed. |
|
Thank you. Type changes need changesets too! Otherwise they won't trigger a patch release (they'll have to wait for something else to do so) and won't show up in the changelog |
|
Ah, I see! Thank you so much for the explanation, Rich. I didn't realize that type-only changes also required a changeset to trigger the patch release. I'll definitely keep this in mind for future contributions. Thrilled to have my first PR merged into Svelte! 🧡 |
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## svelte@5.56.3 ### Patch Changes - fix: ignore errors that occur in destroyed effects ([#18384](#18384)) - fix: type BigInts in `$state.snapshot(...)` return values ([#18388](#18388)) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@sijie-Z For additional context. It's not about types vs no types. It's internal vs external. Internal types doesn't need a changeset. Since these types are external, they're exposed to the user, and a changeset is needed. |
Fixes #18385
Problem
$state.snapshotinfers BigInt properties asneverbecausebigintis missingfrom the
Primitivetype definition. BigInt is a valid JavaScript primitive and issupported by
structuredClone.Solution
Added
bigintto thePrimitivetype in bothpackages/svelte/src/ambient.d.tsandpackages/svelte/types/index.d.ts.Before