mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
angularjs: Reverting to using stronger signatures for IPromise. With tests for that.
This commit is contained in:
@@ -185,22 +185,28 @@ mod.value(My.Namespace);
|
||||
// Promise signature tests
|
||||
var foo: ng.IPromise<number>;
|
||||
foo.then((x) => {
|
||||
// x is infered to be a number. Expected
|
||||
// x is inferred to be a number
|
||||
return "asdf";
|
||||
}).then((x) => {
|
||||
// x is inferred to be string. Awesome
|
||||
// x is inferred to be string
|
||||
x.length;
|
||||
return 123;
|
||||
}).then((x) => {
|
||||
// x is infered to be a number. Awesomer
|
||||
// x is infered to be a number
|
||||
x.toFixed();
|
||||
return;
|
||||
}).then((x) => {
|
||||
// x is infered to be void. Sounds good.
|
||||
// Of course you cannot use x here (typescript will prevent you)
|
||||
// x is infered to be void
|
||||
// Typescript will prevent you to actually use x as a local variable
|
||||
// Try object:
|
||||
return { a: 123 };
|
||||
}).then((x) => {
|
||||
// Still works
|
||||
// Object is inferred here
|
||||
x.a = 123;
|
||||
//Try a promise
|
||||
var y: ng.IPromise<number>;
|
||||
return y;
|
||||
}).then((x) => {
|
||||
// x is infered to be a number, which is the resolved value of a promise
|
||||
x.toFixed();
|
||||
});
|
||||
|
||||
Vendored
+2
-1
@@ -406,7 +406,8 @@ declare module ng {
|
||||
}
|
||||
|
||||
interface IPromise<T> {
|
||||
then(successCallback: (promiseValue: T) => any, errorCallback?: (reason: any) => any): IPromise<any>;
|
||||
then<TResult>(successCallback: (promiseValue: T) => IPromise<TResult>, errorCallback?: (reason: any) => any): IPromise<TResult>;
|
||||
then<TResult>(successCallback: (promiseValue: T) => TResult, errorCallback?: (reason: any) => TResult): IPromise<TResult>;
|
||||
}
|
||||
|
||||
interface IDeferred<T> {
|
||||
|
||||
Reference in New Issue
Block a user