mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-13 21:40:21 +00:00
bluebird: Promise.all takes different types of promises
This commit is contained in:
@@ -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<void>;
|
||||
|
||||
var fooProm: Promise<Foo>;
|
||||
var barProm: Promise<Bar>;
|
||||
var bazProm: Promise<Baz>;
|
||||
|
||||
// - - - - - - - - - - - - - - - - -
|
||||
|
||||
@@ -499,6 +504,30 @@ barProm = fooProm.race<Bar>();
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
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<Foo, Bar>((item: Foo, index: number, arrayLength: number) => {
|
||||
|
||||
Vendored
+5
@@ -464,6 +464,11 @@ declare class Promise<R> implements Promise.Thenable<R>, Promise.Inspection<R> {
|
||||
static all<R>(values: Promise.Thenable<R[]>): Promise<R[]>;
|
||||
// array with promises of value
|
||||
static all<R>(values: Promise.Thenable<R>[]): Promise<R[]>;
|
||||
// array with promises of different types
|
||||
static all<T1, T2>(values: [Promise.Thenable<T1>, Promise.Thenable<T2>]): Promise<[T1, T2]>;
|
||||
static all<T1, T2, T3>(values: [Promise.Thenable<T1>, Promise.Thenable<T2>, Promise.Thenable<T3>]): Promise<[T1, T2, T3]>;
|
||||
static all<T1, T2, T3, T4>(values: [Promise.Thenable<T1>, Promise.Thenable<T2>, Promise.Thenable<T3>, Promise.Thenable<T4>]): Promise<[T1, T2, T3, T4]>;
|
||||
static all<T1, T2, T3, T4, T5>(values: [Promise.Thenable<T1>, Promise.Thenable<T2>, Promise.Thenable<T3>, Promise.Thenable<T4>, Promise.Thenable<T5>]): Promise<[T1, T2, T3, T4, T5]>;
|
||||
// array with values
|
||||
static all<R>(values: R[]): Promise<R[]>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user