43. Exclude
小于 1 分钟
43. Exclude
<题目描述>
::: playground#ts 43. Exclude
@file index.ts
// ============= 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>>,
]
// ============= Your Code Here =============
type MyExclude<T, U> = any
:::
点击查看答案
type MyExclude<T, U> = T extends U ? never : T