pmndrs / valtio

🧙 Valtio makes proxy-state simple for React and Vanilla
https://valtio.dev
MIT License
9.02k stars 251 forks source link

fix(vanilla): Snapshot<T> ignores branded primitive types #748

Closed pastelmind closed 1 year ago

pastelmind commented 1 year ago

Related Issues or Discussions

Fixes #747

Summary

Add the 7 primitive types (string, number, boolean, undefined, null, symbol, bigint) to SnapshotIgnore, so any subtypes of these primitive types are ignored by Snapshot<T>.

This fixes a bug where branded/tagged primitive types (usually created by intersecting them with a faux object type) are incorrectly transformed when passed through Snapshot<T>.

This doesn't handle object-like branded/tagged types, but such types are less common in practice.

Check List

vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
valtio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 7, 2023 2:07pm
codesandbox-ci[bot] commented 1 year ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit edfda2e7ec2584a5c41567e6e4d880fe8cad8259:

Sandbox Source
React Configuration
React Typescript Configuration
React Browserify Configuration
React Snowpack Configuration
React Parcel Configuration