Skip to content

Commit

Permalink
feat(question): add type-challenges#2852 - OmitByType (type-challenge…
Browse files Browse the repository at this point in the history
…s#2853)

Co-authored-by: jiangshan <[email protected]>
  • Loading branch information
github-actions[bot] and jiangshanmeta authored Aug 25, 2021
1 parent 2049fd3 commit 9d743c6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
12 changes: 12 additions & 0 deletions questions/2852-medium-omitbytype/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
From ```T```, pick a set of properties whose type are not assignable to ```U```.

For Example

```typescript
type OmitBoolean = PickByType<{
name: string
count: number
isReadonly: boolean
isEnable: boolean
}, boolean> // { name: string; count: number }
```
7 changes: 7 additions & 0 deletions questions/2852-medium-omitbytype/info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
difficulty: medium
title: OmitByType
tags: object
author:
github: jiangshanmeta
name: jiangshan

1 change: 1 addition & 0 deletions questions/2852-medium-omitbytype/template.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type OmitByType<T, U> = any
14 changes: 14 additions & 0 deletions questions/2852-medium-omitbytype/test-cases.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Equal, Expect, ExpectFalse, NotEqual } from '@type-challenges/utils'

interface Model {
name: string
count: number
isReadonly: boolean
isEnable: boolean
}

type cases = [
Expect<Equal<OmitByType<Model, boolean>, { name: string; count: number }>>,
Expect<Equal<OmitByType<Model, string>, { count: number; isReadonly: boolean; isEnable: boolean }>>,
Expect<Equal<OmitByType<Model, number>, { name: string; isReadonly: boolean; isEnable: boolean }>>,
]

0 comments on commit 9d743c6

Please sign in to comment.