diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 4c03e7c219..6b5e5580a7 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -279,8 +279,14 @@ namespace TestQ { b: string; c: boolean; } + interface TValue { + e: number; + f: boolean; + } var tResult: TResult; var promiseTResult: angular.IPromise; + var tValue: TValue; + var promiseTValue: angular.IPromise; var $q: angular.IQService; var promiseAny: angular.IPromise; @@ -349,6 +355,22 @@ namespace TestQ { let result: angular.IPromise; result = $q.when(tResult); result = $q.when(promiseTResult); + + result = $q.when(tValue, (result: TValue) => tResult); + result = $q.when(tValue, (result: TValue) => tResult, (any) => any); + result = $q.when(tValue, (result: TValue) => tResult, (any) => any, (any) => any); + + result = $q.when(promiseTValue, (result: TValue) => tResult); + result = $q.when(promiseTValue, (result: TValue) => tResult, (any) => any); + result = $q.when(promiseTValue, (result: TValue) => tResult, (any) => any, (any) => any); + + result = $q.when(tValue, (result: TValue) => promiseTResult); + result = $q.when(tValue, (result: TValue) => promiseTResult, (any) => any); + result = $q.when(tValue, (result: TValue) => promiseTResult, (any) => any, (any) => any); + + result = $q.when(promiseTValue, (result: TValue) => promiseTResult); + result = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => any); + result = $q.when(promiseTValue, (result: TValue) => promiseTResult, (any) => any, (any) => any); } } diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index e879668039..0e3e1b214e 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -1041,6 +1041,7 @@ declare namespace angular { * @param value Value or a promise */ when(value: IPromise|T): IPromise; + when(value: IPromise|T, successCallback: (promiseValue: T) => IPromise|TResult, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise; /** * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted. */