60. 扁平化数组
中等
递归地将数组扁平化,直到指定的深度为止。
例如:
type a = FlattenDepth<[1, 2, [3, 4], [[[5]]]], 2> // expected to be [1, 2, 3, 4, [5]]. flattern 2 times
type b = FlattenDepth<[1, 2, [3, 4], [[[5]]]]> // expected to be [1, 2, 3, 4, [[5]]]. Depth defaults to be 1
如果提供了深度,则确保它是一个正整数,如果未提供,默认深度为 1
。