mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #32831 from mprobst/ng-promise
Angular IPromise interop with platform Promise.
This commit is contained in:
@@ -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 {
|
||||
|
||||
Vendored
+14
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user