mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Merge pull request #17281 from kalleguld/master
angular: gave a more precise return type for IQService.all()
This commit is contained in:
@@ -337,6 +337,16 @@ namespace TestQ {
|
||||
let result: angular.IPromise<{a: number; b: string; }>;
|
||||
result = $q.all<{a: number; b: string; }>({a: promiseAny, b: promiseAny});
|
||||
}
|
||||
{
|
||||
let result = $q.all({ num: $q.when(2), str: $q.when('test') });
|
||||
// TS should infer that num is a number and str is a string
|
||||
result.then(r => (r.num * 2) + r.str.indexOf('s'));
|
||||
}
|
||||
{
|
||||
let result = $q.all({ num: $q.when(2), str: 'test' });
|
||||
// TS should infer that num is a number and str is a string
|
||||
result.then(r => (r.num * 2) + r.str.indexOf('s'));
|
||||
}
|
||||
|
||||
// $q.defer
|
||||
{
|
||||
|
||||
3
types/angular/index.d.ts
vendored
3
types/angular/index.d.ts
vendored
@@ -1029,8 +1029,7 @@ declare namespace 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>;
|
||||
all<T>(promises: { [K in keyof T]: (IPromise<T[K]> | T[K]); }): IPromise<T>;
|
||||
/**
|
||||
* Creates a Deferred object which represents a task which will finish in the future.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user