TehShrike/deepmerge

Stack blown with deepmerge.all() using isMergeableObject

nonara opened this issue · 3 comments

Hello. Thanks for your work on deepmerge!

When using all with isMergeableObject and a nested object, it blows the stack in an infinite recursion scenario.

Reproduction:

deepmerge.all([ 
  { "headers": { "h1": "value", "h2": "value" } }, 
  { "b": 3 } 
], { isMergeableObject: () => true })

What would the fix be here, other than "fix your isMergeableObject implementation"?

Ok. I had a look at the code. isMergeableObject is typed isMergeableObject?(value: object): boolean, so I assumed that it was only passing elements which had the object js type. It's actually passing primitives as well.

Adding a typeof value === 'object' check to my isMergeableObject fixes the crash.

Might be worth it to change the call signature to (value:any): boolean

hmm, so that's an issue with the TS typings then