fix: throw proper immer error when applyPatches path traverses null (#1251)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
typeof null === "object" causes isObjectish(null) to return true, silently bypassing the path-resolution guard inside applyPatches_. Traversal then calls getArchtype(null) which accesses null[DRAFT_STATE] and crashes with a native TypeError instead of immer error 18 ("Cannot apply patch, path doesn't resolve"). Add an explicit null check alongside isObjectish so the guard fires correctly and the caller receives the expected immer error message. Fixes: applyPatches({a: null}, [{op: 'add', path: ['a', 'b'], value: 1}])
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- Co-authored-by: JSap0914 <JSap0914@users.noreply.github.com>
Diff stats
2 files+11 added−1 removed
- tests:+9 added−0 removed
- other:+2 added−1 removed