Skip to content

Commit

Permalink
Remove the specialcase intended for strictNullChecks: false in `Awa…
Browse files Browse the repository at this point in the history
…ited`
  • Loading branch information
Andarist committed Feb 24, 2023
1 parent f2df10f commit 7e8f046
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/lib/es5.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1522,12 +1522,11 @@ interface Promise<T> {
* Recursively unwraps the "awaited type" of a type. Non-promise "thenables" should resolve to `never`. This emulates the behavior of `await`.
*/
type Awaited<T> =
T extends null | undefined ? T : // special case for `null | undefined` when not in `--strictNullChecks` mode
T extends object & { then(onfulfilled: infer F, ...args: infer _): any } ? // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped
F extends ((value: infer V, ...args: infer _) => any) ? // if the argument to `then` is callable, extracts the first argument
Awaited<V> : // recursively unwrap the value
never : // the argument to `then` was not callable
T; // non-object or non-thenable
T extends object & { then(onfulfilled: infer F, ...args: infer _): any } ? // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped
F extends ((value: infer V, ...args: infer _) => any) ? // if the argument to `then` is callable, extracts the first 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;
Expand Down

0 comments on commit 7e8f046

Please sign in to comment.