Skip to content

Commit 572c989

Browse files
committed
Merge pull request DefinitelyTyped#4759 from drinchev/master
when.d.ts - add ability to return primitive from catch callback
2 parents 2c96e9e + 93f6359 commit 572c989

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

when/when-tests.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ promise = when(1).catch((err: any) => when(2));
164164
promise = when(1).catch((err: any) => err.good, (err: any) => 2);
165165
promise = when(1).catch((err: any) => err.good, (err: any) => when(2));
166166

167+
promise = when(1).catch(Error, (err: any) => 2);
168+
promise = when(1).catch(Error, (err: any) => when(2));
169+
167170
//TODO: error constructor predicate
168171

169172
promise = when(1).otherwise((err: any) => 2);

when/when.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ declare module When {
174174

175175
// Make sure you test any usage of these overloads, exceptionType must
176176
// be a constructor with prototype set to an instance of Error.
177-
catch<U>(exceptionType: any, onRejected?: (reason: any) => Promise<U>): Promise<U>;
177+
catch<U>(exceptionType: any, onRejected?: (reason: any) => U | Promise<U>): Promise<U>;
178178

179179
finally(onFulfilledOrRejected: Function): Promise<T>;
180180

0 commit comments

Comments
 (0)