diff --git a/types/bluebird/bluebird-tests.ts b/types/bluebird/bluebird-tests.ts index ad60766287244a..34efc81e8c1ae2 100644 --- a/types/bluebird/bluebird-tests.ts +++ b/types/bluebird/bluebird-tests.ts @@ -1,10 +1,12 @@ // Tests by: Bart van der Schoor +// Minimum TypeScript Version: 4.0 // Note: replicate changes to all overloads in both definition and test file // Note: keep both static and instance members inline (so similar) // Note: try to maintain the ordering and separators, and keep to the pattern + import * as Bluebird from "bluebird"; let obj: object = {}; @@ -244,6 +246,14 @@ barProm = barProm.then((value: Bar) => { return Bluebird.resolve(bar); }); +Bluebird.resolve() + .then(() => ["", Bluebird.resolve(0)]) + .all() + .then(([x1, x2]) => { + const y1: string = x1; + const y2: number = x2; + }); + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // $ExpectType Bluebird diff --git a/types/bluebird/index.d.ts b/types/bluebird/index.d.ts index d22c94406ab38b..a3afa82b063038 100644 --- a/types/bluebird/index.d.ts +++ b/types/bluebird/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/petkaantonov/bluebird // Definitions by: Leonard Hecker // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 3.2 +// TypeScript Version: 4.0 /*! * The code following this comment originates from: @@ -58,7 +58,8 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { * The new promise will be rejected or resolved depending on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise. */ // Based on PromiseLike.then, but returns a Bluebird instance. - then(onFulfill?: (value: R) => Resolvable, onReject?: (error: any) => Resolvable): Bluebird; // For simpler signature help. + then(onFulfill?: (value: R) => Resolvable<[...T]>, onReject?: (error: any) => Resolvable<[...T]>): Bluebird<[...T]>; + then(onFulfill?: (value: R) => Resolvable, onReject?: (error: any) => Resolvable): Bluebird; then( onfulfilled?: ((value: R) => Resolvable) | null, onrejected?: ((reason: any) => Resolvable) | null @@ -71,6 +72,7 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { * * Alias `.caught();` for compatibility with earlier ECMAScript version. */ + catch(onReject?: (error: any) => [...T] | undefined | null): Bluebird<[...T] | R>; catch(onReject: ((error: any) => Resolvable) | undefined | null): Bluebird; /** @@ -566,11 +568,8 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { /** * Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too. */ - all(this: Bluebird<[Resolvable, Resolvable, Resolvable, Resolvable, Resolvable]>): Bluebird<[T1, T2, T3, T4, T5]>; - all(this: Bluebird<[Resolvable, Resolvable, Resolvable, Resolvable]>): Bluebird<[T1, T2, T3, T4]>; - all(this: Bluebird<[Resolvable, Resolvable, Resolvable]>): Bluebird<[T1, T2, T3]>; - all(this: Bluebird<[Resolvable, Resolvable]>): Bluebird<[T1, T2]>; - all(this: Bluebird<[Resolvable]>): Bluebird<[T1]>; + + all(this: Bluebird<[...T]>): Bluebird<{ [P in keyof T]: T[P] extends Resolvable ? U : T[P] }>; all(this: Bluebird>>): Bluebird; /** @@ -680,6 +679,7 @@ declare class Bluebird implements PromiseLike, Bluebird.Inspection { /** * Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state. */ + static resolve(value: Bluebird<[...T]>): Bluebird<[...T]>; static resolve(): Bluebird; static resolve(value: Resolvable): Bluebird;