00043-easy-exclude
Easy
built-in
union

Implement the built-in Exclude<T, U>

Exclude from T those types that are assignable to U

For example:

type Result = MyExclude<'a' | 'b' | 'c', 'a'> // 'b' | 'c'

Loading...
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>>,
]