From 4331ee51ba9f79246f8a130db68896e7b624dc89 Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Thu, 27 Jul 2017 14:49:34 +0100 Subject: [PATCH] Add Q.Promise.all, the member function (#18308) --- types/q/v0/index.d.ts | 22 ++++++++++++++++++++++ types/q/v0/q-tests.ts | 2 ++ 2 files changed, 24 insertions(+) diff --git a/types/q/v0/index.d.ts b/types/q/v0/index.d.ts index 11bf8fa7f7..94dc7ef712 100644 --- a/types/q/v0/index.d.ts +++ b/types/q/v0/index.d.ts @@ -166,6 +166,28 @@ declare namespace Q { * - { state: "rejected", reason: } */ inspect(): PromiseState; + + all(this: Promise<[IWhenable, IWhenable, IWhenable, IWhenable, IWhenable, IWhenable]>): Promise<[A, B, C, D, E, F]>; + /** + * Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected. + */ + all(this: Promise<[IWhenable, IWhenable, IWhenable, IWhenable, IWhenable]>): Promise<[A, B, C, D, E]>; + /** + * Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected. + */ + all(this: Promise<[IWhenable, IWhenable, IWhenable, IWhenable]>): Promise<[A, B, C, D]>; + /** + * Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected. + */ + all(this: Promise<[IWhenable, IWhenable, IWhenable]>): Promise<[A, B, C]>; + /** + * Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected. + */ + all(this: Promise<[IWhenable, IWhenable]>): Promise<[A, B]>; + /** + * Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected. + */ + all(this: Promise[]>): Promise; } interface PromiseState { diff --git a/types/q/v0/q-tests.ts b/types/q/v0/q-tests.ts index 5c64fa1ace..9bd95a77c8 100644 --- a/types/q/v0/q-tests.ts +++ b/types/q/v0/q-tests.ts @@ -220,7 +220,9 @@ var y2 = Q().then(() => { return <[typeof s, typeof n]>[s, n]; }); +var p1: Q.Promise<[string, number]> = y1.all(); var p2: Q.Promise<[string, number]> = y1.then(val => Q.all(val)); var p3: Q.Promise<[string, number]> = Q.all(y1); +var p4: Q.Promise<[string, number]> = y2.all(); var p5: Q.Promise<[string, number]> = y2.then(val => Q.all(val)); var p6: Q.Promise<[string, number]> = Q.all(y2);