From 93f6359ec9e5839a22bf01f6aed50ab3d782e90a Mon Sep 17 00:00:00 2001 From: drinchev Date: Sat, 27 Jun 2015 10:42:30 +0200 Subject: [PATCH] when.d.ts - add ability to return primitive from catch callback --- when/when-tests.ts | 3 +++ when/when.d.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/when/when-tests.ts b/when/when-tests.ts index 07ade2c996..6ed82dd32d 100644 --- a/when/when-tests.ts +++ b/when/when-tests.ts @@ -164,6 +164,9 @@ promise = when(1).catch((err: any) => when(2)); promise = when(1).catch((err: any) => err.good, (err: any) => 2); promise = when(1).catch((err: any) => err.good, (err: any) => when(2)); +promise = when(1).catch(Error, (err: any) => 2); +promise = when(1).catch(Error, (err: any) => when(2)); + //TODO: error constructor predicate promise = when(1).otherwise((err: any) => 2); diff --git a/when/when.d.ts b/when/when.d.ts index f646ce7d4f..7ec7213902 100644 --- a/when/when.d.ts +++ b/when/when.d.ts @@ -174,7 +174,7 @@ declare module When { // Make sure you test any usage of these overloads, exceptionType must // be a constructor with prototype set to an instance of Error. - catch(exceptionType: any, onRejected?: (reason: any) => Promise): Promise; + catch(exceptionType: any, onRejected?: (reason: any) => U | Promise): Promise; finally(onFulfilledOrRejected: Function): Promise;