Merge pull request #32831 from mprobst/ng-promise

Angular IPromise interop with platform Promise.
This commit is contained in:
Armando Aguirre
2019-02-06 13:10:38 -08:00
committed by GitHub
3 changed files with 25 additions and 2 deletions
+8
View File
@@ -294,6 +294,14 @@ foo.then((x) => {
x.toFixed();
});
namespace TestPromiseInterop {
declare const promiseInterop: ng.IPromise<number>;
const ngStringPromise: ng.IPromise<string> =
promiseInterop.then((num) => Promise.resolve(String(num)));
const caughtStringPromise: ng.IPromise<string|number> =
promiseInterop.catch((reason) => Promise.resolve('oh noes'));
}
// $q signature tests
namespace TestQ {
interface AbcObject {
+14
View File
@@ -1197,6 +1197,15 @@ declare namespace angular {
* the `notifyCallback` method. The promise can not be resolved or rejected from the
* `notifyCallback` method.
*/
then<TResult1 = T, TResult2 = never>(
successCallback?:
| ((value: T) => PromiseLike<never> | PromiseLike<TResult1> | TResult1)
| null,
errorCallback?:
| ((reason: any) => PromiseLike<never> | PromiseLike<TResult2> | TResult2)
| null,
notifyCallback?: (state: any) => any
): IPromise<TResult1 | TResult2>;
then<TResult1 = T, TResult2 = never>(
successCallback?:
| ((value: T) => IPromise<never> | IPromise<TResult1> | TResult1)
@@ -1210,6 +1219,11 @@ declare namespace angular {
/**
* Shorthand for promise.then(null, errorCallback)
*/
catch<TResult = never>(
onRejected?:
| ((reason: any) => PromiseLike<never> | PromiseLike<TResult> | TResult)
| null
): IPromise<T | TResult>;
catch<TResult = never>(
onRejected?:
| ((reason: any) => IPromise<never> | IPromise<TResult> | TResult)
+3 -2
View File
@@ -11,7 +11,8 @@
"lib": [
"es5",
"dom",
"es2015.iterable"
"es2015.iterable",
"es2015.promise"
],
"noImplicitAny": false,
"noImplicitThis": false,
@@ -25,4 +26,4 @@
"noEmit": true,
"forceConsistentCasingInFileNames": true
}
}
}