Open rimo030 opened 4 months ago
type ConstructTuple<L extends number, R extends any[] = []> = R['length'] extends L ? R : ConstructTuple<L, [...R, unknown]>
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>>, ]