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

Make isBoom type definition laxer #275

Merged
merged 1 commit into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ export interface Output {


/**
* Specifies if an error object is a valid boom object
* Specifies if an object is a valid boom object
*
* @param err - The error object
* @param obj - The object to assess
* @param statusCode - Optional status code
*
* @returns Returns a boolean stating if the error object is a valid boom object and it has the provided statusCode (if present)
*/
export function isBoom(err: Error, statusCode?: number): err is Boom;
export function isBoom(obj: unknown, statusCode?: number): obj is Boom;


/**
Expand Down
6 changes: 3 additions & 3 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ expect.type<boolean>(Boom.boomify(error).isBoom);
expect.type<boolean>(Boom.isBoom(error));
expect.type<boolean>(Boom.isBoom(error, 404));
expect.type<boolean>(Boom.isBoom(Boom.boomify(error)));
expect.type<boolean>(Boom.isBoom('error'));
expect.type<boolean>(Boom.isBoom({ foo: 'bar' }));
expect.type<boolean>(Boom.isBoom({ error: true }));
kanongil marked this conversation as resolved.
Show resolved Hide resolved

expect.error(Boom.isBoom(error, 'test'));
expect.error(Boom.isBoom('error'));
expect.error(Boom.isBoom({ foo: 'bar' }));
expect.error(Boom.isBoom({ error: true }));
expect.error(Boom.isBoom());


Expand Down