Ambiguous error message: "Expected object but got object" when passing an array
liorcode opened this issue · 2 comments
liorcode commented
I got this error when accidentally passing an array in package.json.
It happens because the "but got..." uses typeof value
, which returns "object" for arrays.
Maybe instead of using "typeof" for the error message, using Object.prototype.toString.call(value)
would be better? or something else which would distinguish an array from an object..
Sounds like a small problem but it took me a while to find my package.json error, due to the unclear error message.
iarna commented
Yeah, this is super annoying I agree.
iarna commented
Landed in v1.0.3.