sindresorhus / ow

Function argument validation for humans
https://sindresorhus.com/ow/
MIT License
3.8k stars 105 forks source link

undefined and null aren't handled properly by ow.object #201

Closed hans-hsieh-asus closed 3 years ago

hans-hsieh-asus commented 3 years ago

Step to reproduce

const {default: ow} = require('ow');
ow(null, ow.object.instanceOf(Object)); // throw TypeError
ow(undefined, ow.object.instanceOf(Object)); // throw TypeError

Expected Behavior

Throw ArgumentError (defined in ow)

Actual Behavior

Throw TypeError

wafuwafu13 commented 3 years ago

error detail

~/desktop/ow-tutorial
$ ts-node index.ts

/Users/tagawahirotaka/Desktop/ow-tutorial/node_modules/ow/dist/predicates/object.js:87
                let { name } = object.constructor;
                                      ^
TypeError: Cannot read property 'constructor' of null
    at message (/Users/tagawahirotaka/Desktop/ow-tutorial/node_modules/ow/dist/predicates/object.js:87:39)