Type Challenges Judge

Construct Tuple

提出詳細

type ConstructTuple<L extends number, C extends readonly unknown[] = []> = C["length"] extends L ? C :ConstructTuple<L, [...C, unknown]>;
提出日時2022-07-01 00:01:48
問題Construct Tuple
ユーザーwaki285
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<ConstructTuple<0>, []>>, Expect<Equal<ConstructTuple<2>, [unknown, unknown]>>, Expect<Equal<ConstructTuple<999>['length'], 999>>, // @ts-expect-error Expect<Equal<ConstructTuple<1000>['length'], 1000>>, ]