mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-01 11:50:54 +08:00
angularjs: changed $q.all() (added a type variable and tests)
This commit is contained in:
@@ -242,6 +242,18 @@ foo.then((x) => {
|
||||
x.toFixed();
|
||||
});
|
||||
|
||||
// $q signature tests
|
||||
module TestQ {
|
||||
var $q: ng.IQService;
|
||||
var promise1: ng.IPromise<any>;
|
||||
var promise2: ng.IPromise<any>;
|
||||
|
||||
// $q.all
|
||||
$q.all([promise1, promise2]).then((results: any[]) => {});
|
||||
$q.all<number>([promise1, promise2]).then((results: number[]) => {});
|
||||
$q.all({a: promise1, b: promise2}).then((results: {[id: string]: any;}) => {});
|
||||
$q.all<{a: number; b: string;}>({a: promise1, b: promise2}).then((results: {a: number; b: string;}) => {});
|
||||
}
|
||||
|
||||
var httpFoo: ng.IHttpPromise<number>;
|
||||
httpFoo.then((x) => {
|
||||
|
||||
Vendored
+2
-1
@@ -1006,7 +1006,7 @@ declare module angular {
|
||||
*
|
||||
* @param promises An array of promises.
|
||||
*/
|
||||
all(promises: IPromise<any>[]): IPromise<any[]>;
|
||||
all<T>(promises: IPromise<any>[]): IPromise<T[]>;
|
||||
/**
|
||||
* Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
|
||||
*
|
||||
@@ -1015,6 +1015,7 @@ declare module angular {
|
||||
* @param promises A hash of promises.
|
||||
*/
|
||||
all(promises: { [id: string]: IPromise<any>; }): IPromise<{ [id: string]: any; }>;
|
||||
all<T extends {}>(promises: { [id: string]: IPromise<any>; }): IPromise<T>;
|
||||
/**
|
||||
* Creates a Deferred object which represents a task which will finish in the future.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user