Awaited
提出詳細
type MyAwaited<T extends Promise<any>> = T extends Promise<infer U> ? U extends Promise<any> ? MyAwaited<U> : U : never;
提出日時 | 2023-12-17 13:52:20 |
---|---|
問題 | Awaited |
ユーザー | t-hashimoto-sun |
ステータス | Accepted |
import type { Equal, Expect } from '@type-challenges/utils' type X = Promise<string> type Y = Promise<{ field: number }> type Z = Promise<Promise<string | number>> type cases = [ Expect<Equal<MyAwaited<X>, string>>, Expect<Equal<MyAwaited<Y>, { field: number }>>, Expect<Equal<MyAwaited<Z>, string | number>>, ] // @ts-expect-error type error = MyAwaited<number>