mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[http-errors] don't return never from HttpError constructor
This commit is contained in:
parent
5bb93e3433
commit
68b6849bf5
@ -71,10 +71,6 @@ err = create(404, 'LOL', {id: 1});
|
||||
// create(status, msg, { expose: false })
|
||||
err = create(404, 'LOL', {expose: false});
|
||||
|
||||
// new create.HttpError() should throw: cannot construct abstract class
|
||||
// $ExpectType never
|
||||
new create.HttpError();
|
||||
|
||||
err = new create.NotFound();
|
||||
err = new create.InternalServerError();
|
||||
err = new create[404]();
|
||||
@ -91,9 +87,16 @@ err = new create[404]('This might be a problem');
|
||||
err = new create.MisdirectedRequest();
|
||||
err = new create.MisdirectedRequest('Where should this go?');
|
||||
|
||||
// $ExpectType HttpError
|
||||
new create.HttpError();
|
||||
|
||||
// $ExpectType boolean
|
||||
new Error() instanceof create.HttpError;
|
||||
|
||||
if (err instanceof create.HttpError) {
|
||||
err.statusCode;
|
||||
}
|
||||
|
||||
// should support err instanceof Error
|
||||
create(404) instanceof Error;
|
||||
(new create['404']()) instanceof Error;
|
||||
|
||||
4
types/http-errors/index.d.ts
vendored
4
types/http-errors/index.d.ts
vendored
@ -3,7 +3,7 @@
|
||||
// Definitions by: Tanguy Krotoff <https://github.com/tkrotoff>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
export = createHttpError;
|
||||
|
||||
@ -26,7 +26,7 @@ declare namespace createHttpError {
|
||||
|
||||
type NamedConstructors = {
|
||||
[code: string]: HttpErrorConstructor;
|
||||
HttpError: new (msg?: string) => never;
|
||||
HttpError: HttpErrorConstructor;
|
||||
} & Record<'BadRequest' |
|
||||
'Unauthorized' |
|
||||
'PaymentRequired' |
|
||||
|
||||
Loading…
Reference in New Issue
Block a user