Skip to content

Commit fb1728a

Browse files
committed
feat: add 5423-hard-intersection
1 parent 24e4f93 commit fb1728a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
type MyExtract<T> = T extends unknown[] ? T[number] : T;
2+
type Intersection<T> = T extends [infer F, ...infer R]
3+
? MyExtract<F> & Intersection<R>
4+
: unknown;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { Equal, Expect } from "@type-challenges/utils";
2+
3+
type cases = [
4+
Expect<Equal<Intersection<[[1, 2], [2, 3], [2, 2]]>, 2>>,
5+
Expect<Equal<Intersection<[[1, 2, 3], [2, 3, 4], [2, 2, 3]]>, 2 | 3>>,
6+
Expect<Equal<Intersection<[[1, 2], [3, 4], [5, 6]]>, never>>,
7+
Expect<Equal<Intersection<[[1, 2, 3], [2, 3, 4], 3]>, 3>>,
8+
Expect<Equal<Intersection<[[1, 2, 3], 2 | 3 | 4, 2 | 3]>, 2 | 3>>,
9+
Expect<Equal<Intersection<[[1, 2, 3], 2, 3]>, never>>
10+
];

0 commit comments

Comments
 (0)