diff --git a/types/angular/angular-tests.ts b/types/angular/angular-tests.ts index b83a41a6df..7470fb08bb 100644 --- a/types/angular/angular-tests.ts +++ b/types/angular/angular-tests.ts @@ -294,6 +294,14 @@ foo.then((x) => { x.toFixed(); }); +namespace TestPromiseInterop { + declare const promiseInterop: ng.IPromise; + const ngStringPromise: ng.IPromise = + promiseInterop.then((num) => Promise.resolve(String(num))); + const caughtStringPromise: ng.IPromise = + promiseInterop.catch((reason) => Promise.resolve('oh noes')); +} + // $q signature tests namespace TestQ { interface AbcObject { diff --git a/types/angular/index.d.ts b/types/angular/index.d.ts index 4a8b26fba9..0c28ddbf27 100644 --- a/types/angular/index.d.ts +++ b/types/angular/index.d.ts @@ -1197,6 +1197,15 @@ declare namespace angular { * the `notifyCallback` method. The promise can not be resolved or rejected from the * `notifyCallback` method. */ + then( + successCallback?: + | ((value: T) => PromiseLike | PromiseLike | TResult1) + | null, + errorCallback?: + | ((reason: any) => PromiseLike | PromiseLike | TResult2) + | null, + notifyCallback?: (state: any) => any + ): IPromise; then( successCallback?: | ((value: T) => IPromise | IPromise | TResult1) @@ -1210,6 +1219,11 @@ declare namespace angular { /** * Shorthand for promise.then(null, errorCallback) */ + catch( + onRejected?: + | ((reason: any) => PromiseLike | PromiseLike | TResult) + | null + ): IPromise; catch( onRejected?: | ((reason: any) => IPromise | IPromise | TResult) diff --git a/types/angular/tsconfig.json b/types/angular/tsconfig.json index 46eeb69c7a..590c9c7798 100644 --- a/types/angular/tsconfig.json +++ b/types/angular/tsconfig.json @@ -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 } -} \ No newline at end of file +}