Skip to content
Closed
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
10 changes: 10 additions & 0 deletions types/bluebird/bluebird-tests.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Tests by: Bart van der Schoor <https://github.com/Bartvds>
// 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 = {};
Expand Down Expand Up @@ -244,6 +246,14 @@ barProm = barProm.then((value: Bar) => {
return Bluebird.resolve(bar);
});

Bluebird.resolve()
.then(() => ["", Bluebird.resolve(0)])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're not declaring a tuple here (which was a point I made earlier).

.all()
.then(([x1, x2]) => {
const y1: string = x1;
const y2: number = x2;
});

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

// $ExpectType Bluebird<void | Foo>
Expand Down
14 changes: 7 additions & 7 deletions types/bluebird/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Project: https://github.com/petkaantonov/bluebird
// Definitions by: Leonard Hecker <https://github.com/lhecker>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.2
// TypeScript Version: 4.0

/*!
* The code following this comment originates from:
Expand Down Expand Up @@ -58,7 +58,8 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
* 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<U>(onFulfill?: (value: R) => Resolvable<U>, onReject?: (error: any) => Resolvable<U>): Bluebird<U>; // For simpler signature help.
then<T extends any[]>(onFulfill?: (value: R) => Resolvable<[...T]>, onReject?: (error: any) => Resolvable<[...T]>): Bluebird<[...T]>;
then<T>(onFulfill?: (value: R) => Resolvable<T>, onReject?: (error: any) => Resolvable<T>): Bluebird<T>;
then<TResult1 = R, TResult2 = never>(
onfulfilled?: ((value: R) => Resolvable<TResult1>) | null,
onrejected?: ((reason: any) => Resolvable<TResult2>) | null
Expand All @@ -71,6 +72,7 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
*
* Alias `.caught();` for compatibility with earlier ECMAScript version.
*/
catch<T extends unknown[]>(onReject?: (error: any) => [...T] | undefined | null): Bluebird<[...T] | R>;
catch<U = R>(onReject: ((error: any) => Resolvable<U>) | undefined | null): Bluebird<U | R>;

/**
Expand Down Expand Up @@ -566,11 +568,8 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
/**
* 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<T1, T2, T3, T4, T5>(this: Bluebird<[Resolvable<T1>, Resolvable<T2>, Resolvable<T3>, Resolvable<T4>, Resolvable<T5>]>): Bluebird<[T1, T2, T3, T4, T5]>;
all<T1, T2, T3, T4>(this: Bluebird<[Resolvable<T1>, Resolvable<T2>, Resolvable<T3>, Resolvable<T4>]>): Bluebird<[T1, T2, T3, T4]>;
all<T1, T2, T3>(this: Bluebird<[Resolvable<T1>, Resolvable<T2>, Resolvable<T3>]>): Bluebird<[T1, T2, T3]>;
all<T1, T2>(this: Bluebird<[Resolvable<T1>, Resolvable<T2>]>): Bluebird<[T1, T2]>;
all<T1>(this: Bluebird<[Resolvable<T1>]>): Bluebird<[T1]>;

all<T extends unknown[]>(this: Bluebird<[...T]>): Bluebird<{ [P in keyof T]: T[P] extends Resolvable<infer U> ? U : T[P] }>;
all<R>(this: Bluebird<Iterable<Resolvable<R>>>): Bluebird<R[]>;

/**
Expand Down Expand Up @@ -680,6 +679,7 @@ declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
/**
* 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<T extends unknown[]>(value: Bluebird<[...T]>): Bluebird<[...T]>;
static resolve(): Bluebird<void>;
static resolve<R>(value: Resolvable<R>): Bluebird<R>;

Expand Down