sindresorhus / ow

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

Throw the correct error when second argument to `ow` is `undefined` #239

Closed fnesveda closed 2 years ago

fnesveda commented 2 years ago

When calling ow('value', undefined, ow.string), ow threw an unhelpful error:

TypeError: Cannot read property 'Symbol(test)' of undefined
      at isPredicate
...

because it tried to access a property on an undefined value.

This fixes it so that it throws the right error (as with other, non-undefined values):

Expected second argument to be a predicate or a string, got `undefined`