From fe47b495c8aa7ee551fb3239fb08c93f15a05f92 Mon Sep 17 00:00:00 2001 From: Tobias Bengfort Date: Mon, 21 Jul 2014 11:09:13 +0200 Subject: [PATCH] angularjs: allow $q.when to be called w/o args The current definition does not cover the case that the input type is void. --- angularjs/angular-tests.ts | 6 ++++++ angularjs/angular.d.ts | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 37dae22f4e..d7534bc36b 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -139,6 +139,12 @@ module HttpAndRegularPromiseTests { dPromise.then((snack: string) => { $scope.snack = snack; }); + + // $q.when may be called without arguments + var ePromise: ng.IPromise = $q.when(); + ePromise.then(() => { + $scope.nothing = "really nothing"; + }); } // Test that we can pass around a type-checked success/error Promise Callback diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index d6b649a330..3880a8c05f 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -565,6 +565,12 @@ declare module ng { * @param value Value or a promise */ when(value: T): 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. + * + * @param value Value or a promise + */ + when(): IPromise; } interface IPromise {