题目
中文
构造一个给定长度的元组。
例如
type result = ConstructTuple<2> // 期望得到 [unknown, unkonwn]
English
Construct a tuple with a given length.
For example
type result = ConstructTuple<2> // expect to be [unknown, unkonwn]
答案
type ConstructTuple<
L extends number,
K extends any[] = []
> = K['length'] extends L ? K : ConstructTuple<L, [unknown, ...K]>;
标签:Typescript,ConstructTuple,unknown,length,result,题材,type
From: https://www.cnblogs.com/laggage/p/type-challenge-construct-tuple.html