Skip to content

Commit

Permalink
fix(types): custom Awaited for TS 4.x
Browse files Browse the repository at this point in the history
Fix #1006
  • Loading branch information
posva committed Jan 30, 2022
1 parent a572b15 commit 7fcb62e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/pinia/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ 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): any } // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped
? F extends (value: infer V, ...args: any) => any // if the argument to `then` is callable, extracts the first argument
? Awaited<V> // recursively unwrap the value
? _Awaited<V> // recursively unwrap the value
: never // the argument to `then` was not callable
: T // non-object or non-thenable

Expand Down

0 comments on commit 7fcb62e

Please sign in to comment.