Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't add undefined values to objects when parsing JSON (#2127)
## Summary: Previously, when parsing typed objects from JSON, we would add `[key]: undefined` for any fields that were specified in the parser schema but were absent from the JSON. This was a difference from the behavior of `JSON.parse()` that could cause bugs in some cases (e.g. if a parsed object was spread into another object, it could overwrite existing values with `undefined` when that was not intended). Thus, to better match the behavior of `JSON.parse()`, we now omit `undefined` values from the parsed object if they are not present on the original object. This PR was inspired by test failures on Khan/webapp#28551. I'm making this change out of an abundance of caution. Issue: LEMS-2774 Test plan: `yarn test` Author: benchristel Reviewers: jeremywiebe, handeyeco Required Reviewers: Approved By: jeremywiebe Checks: ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x) Pull Request URL: #2127
- Loading branch information