[Typescript Challenges] 6 Easy - Exclude
作者:互联网
Implement the built-in Exclude<T, U>
For example:
type Result = MyExclude<'a' | 'b' | 'c', 'a'> // 'b' | 'c'
/* _____________ 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>>,
]
标签:Typescript,MyExclude,_____________,utils,Challenges,Expect,Exclude,type 来源: https://www.cnblogs.com/Answer1215/p/16648395.html