Skip to content

Commit

Permalink
TypeScript: Allow custom properties on output.payload (#279)
Browse files Browse the repository at this point in the history
Fixes #277
  • Loading branch information
watson authored Dec 16, 2020
1 parent b25ee43 commit 3a6e4e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ export interface Payload {
The error message derived from error.message
*/
message: string;

/**
* Custom properties
*/
[key: string]: unknown;
}


Expand Down
5 changes: 5 additions & 0 deletions test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ expect.type<Boom.Boom>(new CustomError('Some error'));

const boom = new Boom.Boom('some error');
expect.type<Boom.Output>(boom.output);
boom.output.payload.custom_null = null;
boom.output.payload.custom_number = 42;
boom.output.payload.custom_string = 'foo';
boom.output.payload.custom_boolean = true;
boom.output.payload.custom_object = { bar: 42 };
expect.type<Boom.Payload>(boom.output.payload);


Expand Down

0 comments on commit 3a6e4e7

Please sign in to comment.