-
Notifications
You must be signed in to change notification settings - Fork 0
/
00043-easy-exclude.ts
45 lines (35 loc) · 1.03 KB
/
00043-easy-exclude.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
43 - Exclude
-------
by Zheeeng (@zheeeng) #easy #built-in
### Question
Implement the built-in Exclude<T, U>
> Exclude from T those types that are assignable to U
> View on GitHub: https://tsch.js.org/43
*/
/* _____________ Your Code Here _____________ */
type MyExclude<T, U> = T extends U ? never : T;
/* _____________ Test Cases _____________ */
import type { Equal, Expect } from "@type-challenges/utils";
type cases = [
Expect<Equal<MyExclude<"a" | "b" | "c", "a">, Exclude<"a" | "b" | "c", "a">>>,
Expect<
Equal<
MyExclude<"a" | "b" | "c", "a" | "b">,
Exclude<"a" | "b" | "c", "a" | "b">
>
>,
Expect<
Equal<
MyExclude<string | number | (() => void), Function>,
Exclude<string | number | (() => void), Function>
>
>
];
type a = MyExclude<'a' | 'b' | 'c', 'a'>
/* _____________ Further Steps _____________ */
/*
> Share your solutions: https://tsch.js.org/43/answer
> View solutions: https://tsch.js.org/43/solutions
> More Challenges: https://tsch.js.org
*/