mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-24 05:47:44 +08:00
Improve catch with constructor filter.
Add arguments to constructor's `new()` signature + tests
This commit is contained in:
@@ -347,6 +347,18 @@ fooOrBarProm = fooProm.caught(Promise.CancellationError, (reason: any) => {
|
||||
})
|
||||
}
|
||||
|
||||
{
|
||||
class CustomErrorWithConstructor extends Error {
|
||||
constructor(public arg1: boolean, public arg2: number) {
|
||||
super();
|
||||
};
|
||||
}
|
||||
fooProm = fooProm.catch(CustomErrorWithConstructor, reason => {
|
||||
let a: boolean = reason.arg1;
|
||||
let b: number = reason.arg2;
|
||||
})
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
barProm = fooProm.error((reason: any) => {
|
||||
|
||||
8
bluebird/bluebird.d.ts
vendored
8
bluebird/bluebird.d.ts
vendored
@@ -75,11 +75,11 @@ class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R> {
|
||||
catch<U>(predicate: (error: any) => boolean, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
|
||||
caught<U>(predicate: (error: any) => boolean, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
|
||||
|
||||
catch<E>(ErrorClass: new () => E, onReject: (error: E) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
|
||||
caught<E>(ErrorClass: new () => E, onReject: (error: E) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
|
||||
catch<E>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
|
||||
caught<E>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
|
||||
|
||||
catch<E, U>(ErrorClass: new () => E, onReject: (error: E) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
|
||||
caught<E, U>(ErrorClass: new () => E, onReject: (error: E) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
|
||||
catch<E, U>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
|
||||
caught<E, U>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
|
||||
|
||||
catch(predicate: Object, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
|
||||
caught(predicate: Object, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
|
||||
|
||||
Reference in New Issue
Block a user