Skip to content

Commit b23f44a

Browse files
authored
Simplify a branch of the Awaited type and clean up comments (#45918)
1 parent 6aaefe4 commit b23f44a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/lib/es5.d.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -1477,13 +1477,11 @@ interface Promise<T> {
14771477
*/
14781478
type Awaited<T> =
14791479
T extends null | undefined ? T : // special case for `null | undefined` when not in `--strictNullChecks` mode
1480-
T extends object ? // `await` only unwraps object types with a callable then. Non-object types are not unwrapped.
1481-
T extends { then(onfulfilled: infer F): any } ? // thenable, extracts the first argument to `then()`
1482-
F extends ((value: infer V) => any) ? // if the argument to `then` is callable, extracts the argument
1483-
Awaited<V> : // recursively unwrap the value
1484-
never : // the argument to `then` was not callable.
1485-
T : // argument was not an object
1486-
T; // non-thenable
1480+
T extends object & { then(onfulfilled: infer F): any } ? // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped
1481+
F extends ((value: infer V) => any) ? // if the argument to `then` is callable, extracts the argument
1482+
Awaited<V> : // recursively unwrap the value
1483+
never : // the argument to `then` was not callable
1484+
T; // non-object or non-thenable
14871485

14881486
interface ArrayLike<T> {
14891487
readonly length: number;

0 commit comments

Comments
 (0)