Back to Type Challenges

README

questions/00189-easy-awaited/README.md

latest2.0 KB
Original Source
<!--info-header-start--><h1>Awaited </h1><blockquote><p>by Maciej Sikora <a href="https://github.com/maciejsikora" target="_blank">@maciejsikora</a></p></blockquote><p><a href="https://tsch.js.org/189/play" target="_blank"></a> &nbsp;&nbsp;&nbsp;<a href="./README.zh-CN.md" target="_blank"></a> <a href="./README.ja.md" target="_blank"></a> <a href="./README.ko.md" target="_blank"></a> </p><!--info-header-end-->

If we have a type which is a wrapped type like Promise, how can we get the type which is inside the wrapped type?

For example: if we have Promise<ExampleType> how to get ExampleType?

ts
type ExampleType = Promise<string>

type Result = MyAwaited<ExampleType> // string

This question is ported from the original article by @maciejsikora

<!--info-footer-start-->

<a href="../../README.md" target="_blank"></a> <a href="https://tsch.js.org/189/answer" target="_blank"></a> <a href="https://tsch.js.org/189/solutions" target="_blank"></a> <!--info-footer-end-->