MyExclude<T, U>
EasyP1Coding
Implement the built-in Exclude<T, U> generic without using it.
MyExclude<T, U> removes from the union T every member that is assignable to U.
Tests your type must pass
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>>, Expect<Equal<MyExclude<'a' | 'b', 'z'>, 'a' | 'b'>>, Expect<Equal<MyExclude<'a' | 'b', 'a' | 'b'>, never>>, ]
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
TypeScript
Run and Submit type-check your solution against the tests. ⌘Enter runs, ⌘⇧Enter submits.