From 82fd25f50b1ac2d1ef04fb438d86d09362eae7df Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 16 Sep 2021 13:50:59 -0700 Subject: [PATCH] Simplify a branch of the Awaited type and clean up comments --- src/lib/es5.d.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 93fd3986e8c38..8f803453c1689 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1477,13 +1477,11 @@ interface Promise { */ type Awaited = T extends null | undefined ? T : // special case for `null | undefined` when not in `--strictNullChecks` mode - T extends object ? // `await` only unwraps object types with a callable then. Non-object types are not unwrapped. - T extends { then(onfulfilled: infer F): any } ? // thenable, extracts the first argument to `then()` - F extends ((value: infer V) => any) ? // if the argument to `then` is callable, extracts the argument - Awaited : // recursively unwrap the value - never : // the argument to `then` was not callable. - T : // argument was not an object - T; // non-thenable + T extends object & { then(onfulfilled: infer F): any } ? // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped + F extends ((value: infer V) => any) ? // if the argument to `then` is callable, extracts the argument + Awaited : // recursively unwrap the value + never : // the argument to `then` was not callable + T; // non-object or non-thenable interface ArrayLike { readonly length: number;