Type Challenges Judge

Intersection

提出詳細

type Intersection<T extends unknown[]> = T extends [infer L, ...infer R] ? L extends unknown[] ? L[number] & Intersection<R> : L & Intersection<R> : unknown
提出日時2024-09-12 15:14:58
問題Intersection
ユーザーookkoouu
ステータスAccepted
テストケース
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<Intersection<[[1, 2], [2, 3], [2, 2]]>, 2>>, Expect<Equal<Intersection<[[1, 2, 3], [2, 3, 4], [2, 2, 3]]>, 2 | 3>>, Expect<Equal<Intersection<[[1, 2], [3, 4], [5, 6]]>, never>>, Expect<Equal<Intersection<[[1, 2, 3], [2, 3, 4], 3]>, 3>>, Expect<Equal<Intersection<[[1, 2, 3], 2 | 3 | 4, 2 | 3]>, 2 | 3>>, Expect<Equal<Intersection<[[1, 2, 3], 2, 3]>, never>>, ]