[Typescript Challenges] 6 Easy - Exclude
typescript Easy
2023-09-14 08:59:12 时间
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] noImplicitOverride
- [Typescript Challenges] 7. Easy - Awaited
- [Typescript Challenges] 4. Easy - First of Array
- [Typescript Challenges] 1. Easy - Pick
- [Typescript] Step 7. Tests for Types
- [Typescript] Making TypeScript Stick - 6 - infer, build a ConstructorArg Type
- [Typescript] Ignore Null or Undefined Values with TypeScript Non-Null Assertion Operator
- [Typescript] Make TypeScript Class Usage Safer with Strict Property Initialization
- [TypeScript] Using Typings and Loading From node_modules
- [Typescript] DOMNodeExtractorConfig
- [Typescript] 108. Easy - Nullable
- [Typescript] Zod in action
- [Typescript] Declare Module
- [Typescript] 12. Easy - Push
- [Typescript Challenges] 7. Easy - Awaited
- [Typescript Challenges] 6 Easy - Exclude
- [Typescript Challenges] 5. Easy - Length of Tuple
- [Typescript] Making TypeScript Stick - 5 - Extends
- [Typescript] Extend Functionality of a TypeScript Class with Decorators
- [Typescript] Exclude Properties from a Type in TypeScript (Omit)
- [React] Use React.ReactNode for the children prop in React TypeScript components and Render Props
- [Typescript] Make TypeScript Class Usage Safer with Strict Property Initialization
- [Angular] Short Imports with TypeScript Path Mapping
- [RxJS] Add debug method to Observable in TypeScript
- 使用 TypeScript 编写 SAP UI5 应用的准备工作
- QCChart2D Charting for JavaScript/TypeScript