144. 提取公共元素
困难
实现 Lodash.intersection
的类型版本 Intersection<T>
,不过它们稍有不同,接受一个包含多个数组或任何类型元素(包括联合类型)的数组 T
,并返回一个新的联合类型,包含所有交集元素。
例如:
type Res = Intersection<[[1, 2], [2, 3], [2, 2]]> // expected to be 2
type Res1 = Intersection<[[1, 2, 3], [2, 3, 4], [2, 2, 3]]> // expected to be 2 | 3
type Res2 = Intersection<[[1, 2], [3, 4], [5, 6]]> // expected to be never
type Res3 = Intersection<[[1, 2, 3], [2, 3, 4], 3]> // expected to be 3
type Res4 = Intersection<[[1, 2, 3], 2 | 3 | 4, 2 | 3]> // expected to be 2 | 3
type Res5 = Intersection<[[1, 2, 3], 2, 3]> // expected to be never