-
Notifications
You must be signed in to change notification settings - Fork 0
/
00043-easy-exclude.ts
45 lines (28 loc) · 962 Bytes
/
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
/*
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
For example:
```ts
type Result = MyExclude<'a' | 'b' | 'c', 'a'> // 'b' | 'c'
```
> 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'>, 'b' | 'c'>>,
Expect<Equal<MyExclude<'a' | 'b' | 'c', 'a' | 'b'>, 'c'>>,
Expect<Equal<MyExclude<string | number | (() => void), Function>, string | number>>,
]
/* _____________ 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
*/