-
-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constrain BaseController state to be valid JSON #366
Conversation
|
The BaseController state is now constrained to valid JSON. Anything that can't be serialized (e.g. functions) or gets mutated during serialization (e.g. `undefined` gets converted to `null`) is disallowed. This should prevent an entire class of bugs resulting from unexpected changes when serializing state as JSON. For example, we serialize state when sending it over `postMessage`, and when persisting the state.
7862dc2
to
91e9715
Compare
Note that I haven't added any test cases for this type, as testing that types work properly can be a bit challenging. But the comment I got this type from did include a TypeScript playground link will a comprehensive set of tests. I had intended to look into something like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Dope!
that type is ingenious. |
The BaseController state is now constrained to valid JSON. Anything that can't be serialized (e.g. functions) or gets mutated during serialization (e.g. `undefined` gets converted to `null`) is disallowed. This should prevent an entire class of bugs resulting from unexpected changes when serializing state as JSON. For example, we serialize state when sending it over `postMessage`, and when persisting the state.
The BaseController state is now constrained to valid JSON. Anything that can't be serialized (e.g. functions) or gets mutated during serialization (e.g. `undefined` gets converted to `null`) is disallowed. This should prevent an entire class of bugs resulting from unexpected changes when serializing state as JSON. For example, we serialize state when sending it over `postMessage`, and when persisting the state.
The BaseController state is now constrained to valid JSON. Anything that can't be serialized (e.g. functions) or gets mutated during
serialization (e.g.
undefined
gets converted tonull
) is disallowed.This should prevent an entire class of bugs resulting from unexpected changes when serializing state as JSON. For example, we serialize state when sending it over
postMessage
, and when persisting the state.