Skip to content

Commit 5774cd3

Browse files
authored
Better typings for Promise.then(), like microsoft#31117
1 parent 4fc12d7 commit 5774cd3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/lib/es5.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ interface PromiseLike<T> {
13701370
* @param onrejected The callback to execute when the Promise is rejected.
13711371
* @returns A Promise for the completion of which ever callback is executed.
13721372
*/
1373-
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): PromiseLike<TResult1 | TResult2>;
1373+
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T extends PromiseLike<infer U> ? U : T) => TResult1) | undefined | null, onrejected?: ((reason: any) => TResult2) | undefined | null): PromiseLike<TResult1 | TResult2>;
13741374
}
13751375

13761376
/**
@@ -1383,14 +1383,14 @@ interface Promise<T> {
13831383
* @param onrejected The callback to execute when the Promise is rejected.
13841384
* @returns A Promise for the completion of which ever callback is executed.
13851385
*/
1386-
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Promise<TResult1 | TResult2>;
1386+
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T extends PromiseLike<infer U> ? U : T) => TResult1) | undefined | null, onrejected?: ((reason: any) => TResult2) | undefined | null): Promise<TResult1 | TResult2>;
13871387

13881388
/**
13891389
* Attaches a callback for only the rejection of the Promise.
13901390
* @param onrejected The callback to execute when the Promise is rejected.
13911391
* @returns A Promise for the completion of the callback.
13921392
*/
1393-
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): Promise<T | TResult>;
1393+
catch<TResult = never>(onrejected?: ((reason: any) => TResult) | undefined | null): Promise<T | TResult>;
13941394
}
13951395

13961396
interface ArrayLike<T> {

0 commit comments

Comments
 (0)