Construct Tuple
提出詳細
type ConstructTuple<L extends number, Acc extends readonly unknown[]=[]> = Acc["length"] extends L ? Acc : ConstructTuple<L, [...Acc, unknown]>
提出日時 | 2023-09-18 12:49:29 |
---|---|
問題 | Construct Tuple |
ユーザー | sankantsu |
ステータス | 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>>, ]