Skip to content

Commit

Permalink
Throw the correct error when second argument to ow is undefined (#…
Browse files Browse the repository at this point in the history
…239)

Co-authored-by: Sindre Sorhus <[email protected]>
  • Loading branch information
fnesveda and sindresorhus authored Jun 13, 2022
1 parent 391fc91 commit 147b479
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/predicates/base-predicate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const testSymbol: unique symbol = Symbol('test');
/**
@hidden
*/
export const isPredicate = (value: unknown): value is BasePredicate => Boolean((value as any)[testSymbol]);
export const isPredicate = (value: unknown): value is BasePredicate => Boolean((value as any)?.[testSymbol]);

/**
@hidden
Expand Down
4 changes: 4 additions & 0 deletions test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,10 @@ test('ow without valid arguments', t => {
t.throws(() => {
ow(5, {} as any);
}, {message: 'Expected second argument to be a predicate or a string, got `object`'});

t.throws(() => {
ow(5, undefined);
}, {message: 'Expected second argument to be a predicate or a string, got `undefined`'});
});

// Skipped because require is not defined in esm
Expand Down

0 comments on commit 147b479

Please sign in to comment.