mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge pull request #2539 from xi/feature-angularjs-when-void
angularjs: allow $q.when to be called w/o args
This commit is contained in:
@@ -95,6 +95,7 @@ module HttpAndRegularPromiseTests {
|
||||
theAnswer: number;
|
||||
letters: string[];
|
||||
snack: string;
|
||||
nothing?: string;
|
||||
}
|
||||
|
||||
var someController: Function = ($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) => {
|
||||
@@ -139,6 +140,12 @@ module HttpAndRegularPromiseTests {
|
||||
dPromise.then((snack: string) => {
|
||||
$scope.snack = snack;
|
||||
});
|
||||
|
||||
// $q.when may be called without arguments
|
||||
var ePromise: ng.IPromise<void> = $q.when();
|
||||
ePromise.then(() => {
|
||||
$scope.nothing = "really nothing";
|
||||
});
|
||||
}
|
||||
|
||||
// Test that we can pass around a type-checked success/error Promise Callback
|
||||
|
||||
Vendored
+6
@@ -565,6 +565,12 @@ declare module ng {
|
||||
* @param value Value or a promise
|
||||
*/
|
||||
when<T>(value: T): IPromise<T>;
|
||||
/**
|
||||
* 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<void>;
|
||||
}
|
||||
|
||||
interface IPromise<T> {
|
||||
|
||||
Reference in New Issue
Block a user