Skip to content

Commit fe47b49

Browse files
author
Tobias Bengfort
committed
angularjs: allow $q.when to be called w/o args
The current definition does not cover the case that the input type is void.
1 parent 5326ecd commit fe47b49

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

angularjs/angular-tests.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ module HttpAndRegularPromiseTests {
139139
dPromise.then((snack: string) => {
140140
$scope.snack = snack;
141141
});
142+
143+
// $q.when may be called without arguments
144+
var ePromise: ng.IPromise<Person> = $q.when();
145+
ePromise.then(() => {
146+
$scope.nothing = "really nothing";
147+
});
142148
}
143149

144150
// Test that we can pass around a type-checked success/error Promise Callback

angularjs/angular.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,12 @@ declare module ng {
565565
* @param value Value or a promise
566566
*/
567567
when<T>(value: T): IPromise<T>;
568+
/**
569+
* 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.
570+
*
571+
* @param value Value or a promise
572+
*/
573+
when(): IPromise<void>;
568574
}
569575

570576
interface IPromise<T> {

0 commit comments

Comments
 (0)