iarna / aproba

A ridiculously light-weight function argument validator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ambiguous error message: "Expected object but got object" when passing an array

liorcode opened this issue · comments

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.

Yeah, this is super annoying I agree.

Landed in v1.0.3.