From 5774cd3c6016b23ce983eeaa03e85dc83bc2bb46 Mon Sep 17 00:00:00 2001 From: Jack Bates Date: Tue, 27 Aug 2019 11:03:07 -0700 Subject: [PATCH] Better typings for Promise.then(), like #31117 --- src/lib/es5.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 3eced36c0778d..496e2f22a9af3 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1370,7 +1370,7 @@ interface PromiseLike { * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ - then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): PromiseLike; + then(onfulfilled?: ((value: T extends PromiseLike ? U : T) => TResult1) | undefined | null, onrejected?: ((reason: any) => TResult2) | undefined | null): PromiseLike; } /** @@ -1383,14 +1383,14 @@ interface Promise { * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ - then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): Promise; + then(onfulfilled?: ((value: T extends PromiseLike ? U : T) => TResult1) | undefined | null, onrejected?: ((reason: any) => TResult2) | undefined | null): Promise; /** * Attaches a callback for only the rejection of the Promise. * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of the callback. */ - catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): Promise; + catch(onrejected?: ((reason: any) => TResult) | undefined | null): Promise; } interface ArrayLike {