Hi, there
Since our team recently upgraded set-value from v3 to v4, we found there's a severe problem dealing with numeric path.
before v4 paths are treated as properties, so it worked as expected like the following example

but since array index supported in v4, path contains numbers that causes target object's value transformed into an array anyway, and all its properties are gone.

the root cause might be on
|
if (typeof next === 'number' && !Array.isArray(obj[key])) { |
|
obj = obj[key] = []; |
|
continue; |
but the quandary is, how to determine a numeric path is tending to set value to an array index or an object property?
I made a codesandbox to reproduce this issue, versions switch is available on the left panel, please let me know if any further information is needed
Hi, there
Since our team recently upgraded set-value from v3 to v4, we found there's a severe problem dealing with numeric path.

before v4 paths are treated as properties, so it worked as expected like the following example
but since array index supported in v4, path contains numbers that causes target object's value transformed into an array anyway, and all its properties are gone.

the root cause might be on
set-value/index.js
Lines 148 to 150 in c574eb8
but the quandary is, how to determine a numeric path is tending to set value to an array index or an object property?
I made a codesandbox to reproduce this issue, versions switch is available on the left panel, please let me know if any further information is needed