mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 11:54:44 -06:00
Simplify a branch of the Awaited type and clean up comments (#45918)
This commit is contained in:
parent
6aaefe41fe
commit
b23f44aee5
12
src/lib/es5.d.ts
vendored
12
src/lib/es5.d.ts
vendored
@ -1477,13 +1477,11 @@ interface Promise<T> {
|
||||
*/
|
||||
type Awaited<T> =
|
||||
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<V> : // 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<V> : // recursively unwrap the value
|
||||
never : // the argument to `then` was not callable
|
||||
T; // non-object or non-thenable
|
||||
|
||||
interface ArrayLike<T> {
|
||||
readonly length: number;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user