Promise.all
提出詳細
// T extends readonly unknown[]だとreadonly配列が返却されるため[...T]が必要 declare function PromiseAll<T extends unknown[]>(args: readonly [...T]): Promise<{ [P in keyof T]: T[P] extends Promise<infer S> ? S : T[P] }>
提出日時 | 2023-04-30 22:23:55 |
---|---|
問題 | Promise.all |
ユーザー | Dowanna |
ステータス | Accepted |
import type { Equal, Expect } from '@type-challenges/utils' const promiseAllTest1 = PromiseAll([1, 2, 3] as const) const promiseAllTest2 = PromiseAll([1, 2, Promise.resolve(3)] as const) const promiseAllTest3 = PromiseAll([1, 2, Promise.resolve(3)]) type cases = [ Expect<Equal<typeof promiseAllTest1, Promise<[1, 2, 3]>>>, Expect<Equal<typeof promiseAllTest2, Promise<[1, 2, number]>>>, Expect<Equal<typeof promiseAllTest3, Promise<[number, number, number]>>>, ]