Skip to content

Question about Awaited type #12837

Answered by JonghwanWon
Dovakeidy asked this question in Q&A
Discussion options

You must be logged in to vote

The solution you submitted does not solve Promise of recursive case.

type ExampleType = Promise<Promise<string>> // nested promises.

type MyAwaited<T extends Promise<any>> = T extends Promise<infer R>
  ? R
  : never;

type Result = MyAwaited<ExampleType> // Promise<string>

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Dovakeidy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants