Type Challenges Judge

Promise.all

提出詳細

type Resolve<T> = T extends Promise<infer R> ? R : T; type ResultArray<T extends readonly any[]> = {[K in keyof T]: Resolve<T[K]>} declare function PromiseAll<T extends any[]>(values: readonly [...T]): Promise<ResultArray<T>>;
提出日時2022-10-12 14:54:03
問題Promise.all
ユーザーyotarotsukada
ステータス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]>>>, ]