microdiff icon indicating copy to clipboard operation
microdiff copied to clipboard

Cannot use 'in' operator to search for ... in null

Open zarmin opened this issue 4 years ago • 5 comments

const diff = require('microdiff').default
const a1 = {"a": { "b": 1 }}
const a2 = {"a": null}
console.log(diff(a1, a2))
/Users/.../node_modules/microdiff/dist/index.cjs:8
		if (!(key in newObj)) {
		          ^

TypeError: Cannot use 'in' operator to search for 'b' in null

zarmin avatar Nov 07 '21 14:11 zarmin

Thanks for reporting this! I will work on a fix, it should not take long.

AsyncBanana avatar Nov 07 '21 15:11 AsyncBanana

Ok, this should be fixed now. Let me know if you continue to have problems with this in version v1.1.1+.

AsyncBanana avatar Nov 07 '21 15:11 AsyncBanana

@AsyncBanana I'm having same issue in "microdiff": "^1.3.2"

AbdallahAbis avatar Jan 09 '24 17:01 AbdallahAbis

Could you send me the relevant code?

AsyncBanana avatar Jan 09 '24 18:01 AsyncBanana

Getting the same issue (comparing arrays of objects with arrays inside). It happens when the root object is undefined or null (might want to check that).

AndreyMay avatar Jul 07 '24 02:07 AndreyMay