diff --git a/bluebird/bluebird-tests.ts b/bluebird/bluebird-tests.ts index b8eecf2cad..ade4610743 100644 --- a/bluebird/bluebird-tests.ts +++ b/bluebird/bluebird-tests.ts @@ -36,6 +36,9 @@ interface Foo { interface Bar { bar(): string; } +interface Baz { + baz(): string; +} // - - - - - - - - - - - - - - - - - @@ -61,6 +64,7 @@ interface StrBarArrMap { var foo: Foo; var bar: Bar; +var baz: Baz; var fooArr: Foo[]; var barArr: Bar[]; @@ -76,6 +80,7 @@ var voidProm: Promise; var fooProm: Promise; var barProm: Promise; +var bazProm: Promise; // - - - - - - - - - - - - - - - - - @@ -499,6 +504,30 @@ barProm = fooProm.race(); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +Promise.all([fooProm, barProm]).then(result => { + result[0].foo(); + result[1].bar(); +}); + +Promise.all([fooProm, fooProm]).then(result => { + result[0].foo(); + result[1].foo(); +}); + +Promise.all([fooProm, barProm, bazProm]).then(result => { + result[0].foo(); + result[1].bar(); + result[2].baz(); +}); + +Promise.all([fooProm, barProm, fooProm]).then(result => { + result[0].foo(); + result[1].bar(); + result[2].foo(); +}); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + //TODO fix collection inference barArrProm = fooProm.map((item: Foo, index: number, arrayLength: number) => { diff --git a/bluebird/bluebird.d.ts b/bluebird/bluebird.d.ts index 350761fddc..878e1051e8 100644 --- a/bluebird/bluebird.d.ts +++ b/bluebird/bluebird.d.ts @@ -464,6 +464,11 @@ declare class Promise implements Promise.Thenable, Promise.Inspection { static all(values: Promise.Thenable): Promise; // array with promises of value static all(values: Promise.Thenable[]): Promise; + // array with promises of different types + static all(values: [Promise.Thenable, Promise.Thenable]): Promise<[T1, T2]>; + static all(values: [Promise.Thenable, Promise.Thenable, Promise.Thenable]): Promise<[T1, T2, T3]>; + static all(values: [Promise.Thenable, Promise.Thenable, Promise.Thenable, Promise.Thenable]): Promise<[T1, T2, T3, T4]>; + static all(values: [Promise.Thenable, Promise.Thenable, Promise.Thenable, Promise.Thenable, Promise.Thenable]): Promise<[T1, T2, T3, T4, T5]>; // array with values static all(values: R[]): Promise;