Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) && Boolean((value as any)[testSymbol]);
fnesveda marked this conversation as resolved.
Show resolved Hide resolved

/**
@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