fix : applied nested path construction from null/empty objects in setIn - #3198
fix : applied nested path construction from null/empty objects in setIn#3198tmdeveloper007 wants to merge 5 commits into
Conversation
|
Warning Review limit reached
Next review available in: 46 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of What Has Been Done
Fixed
setIn()inpackages/store/src/immutable.tsto correctly construct nested paths when the source object isnullor an empty object. Previously,setIn(null, ['a', 'b'], 'value')returned{}instead of{ a: { b: 'value' } }, andsetIn(null, ['a', 0, 'b'], 'value')returned{ a: { '0': [] } }instead of{ a: [{ b: 'value' }] }.Changes Made
packages/store/src/immutable.ts
objis a plain object cloned via{ ...obj }and the next key is numeric withObject.keys(clone).length === 0, replaceclonewith[]to ensure numeric keys create real array elements instead of string-keyed object properties.rest.length === 0), ifcloneis an array and the key is a string, convert to a plain object before assignment so the property survives JSON serialization.packages/store/src/immutable.test.ts
setIn from null builds nested path correctlysetIn from null with numeric index creates array14 tests pass.
Impact it Made
Makes
setIncorrectly handle cases where state is initialized fromnullor where paths reference deeply nested keys that have never been set. This is a common pattern in UI state trees and Redux-style stores.Closes #3193
**Note: Please assign this PR to the
tmdeveloper007account.