Skip to content

Commit b9087cd

Browse files
committed
feat: add pick and omit
1 parent 672f29c commit b9087cd

File tree

19 files changed

+109
-3
lines changed

19 files changed

+109
-3
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ English | <a href='./README.zh-CN.md'>简体中文</a>
2525
2626
## Challenges
2727

28+
> ![](https://img.shields.io/badge/-warm--up-yellow) ![](https://img.shields.io/badge/-easy-green) ![](https://img.shields.io/badge/-medium-orange) ![](https://img.shields.io/badge/-hard-red) ![](https://img.shields.io/badge/-extreme-purple)
29+
2830
<!--challenges-start-->
29-
<a href="https://type-challenges.netlify.app/case/2/play/en"><img src="https://img.shields.io/badge/-%232%20--%20Get%20Return%20Type-green"/></a>
31+
<a href="https://type-challenges.netlify.app/case/2/play/en"><img src="https://img.shields.io/badge/-%232%20--%20Get%20Return%20Type-orange"/></a> <a href="https://type-challenges.netlify.app/case/3/play/en"><img src="https://img.shields.io/badge/-%233%20--%20Omit%3CT%2C%20K%3E-green"/></a> <a href="https://type-challenges.netlify.app/case/3/play/en"><img src="https://img.shields.io/badge/-%233%20--%20Pick%3CT%2C%20K%3E-green"/></a>
3032
<!--challenges-end-->
3133

3234
</details>

README.zh-CN.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ TypeScript 类型体操姿势合集
2525
2626
## Challenges
2727

28+
> ![](https://img.shields.io/badge/-热身-yellow) ![](https://img.shields.io/badge/-简单-green) ![](https://img.shields.io/badge/-中等-orange) ![](https://img.shields.io/badge/-困难-red) ![](https://img.shields.io/badge/-地狱-purple)
29+
2830
<!--challenges-start-->
29-
<a href="https://type-challenges.netlify.app/case/2/play/zh-CN"><img src="https://img.shields.io/badge/-%232%20--%20%E8%8E%B7%E5%8F%96%E5%87%BD%E6%95%B0%E8%BF%94%E5%9B%9E%E7%B1%BB%E5%9E%8B-green"/></a>
31+
<a href="https://type-challenges.netlify.app/case/2/play/zh-CN"><img src="https://img.shields.io/badge/-%232%20--%20%E8%8E%B7%E5%8F%96%E5%87%BD%E6%95%B0%E8%BF%94%E5%9B%9E%E7%B1%BB%E5%9E%8B-orange"/></a> <a href="https://type-challenges.netlify.app/case/3/play/zh-CN"><img src="https://img.shields.io/badge/-%233%20--%20%E5%AE%9E%E7%8E%B0%20Omit%3CT%2C%20K%3E-green"/></a> <a href="https://type-challenges.netlify.app/case/3/play/zh-CN"><img src="https://img.shields.io/badge/-%233%20--%20%E5%AE%9E%E7%8E%B0%20Pick%3CT%2C%20K%3E-green"/></a>
3032
<!--challenges-end-->
3133

3234
## How to Contribute
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

questions/3-easy-omit/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Implement the built-in `Omit<T, K>` generic without using it.
2+
3+
Constructs a type by picking all properties from `T` and then removing `K`
4+
5+
For example
6+
7+
```ts
8+
interface Todo {
9+
title: string
10+
description: string
11+
completed: boolean
12+
}
13+
14+
type TodoPreview = MyOmit<Todo, 'description'>
15+
16+
const todo: TodoPreview = {
17+
title: 'Clean room',
18+
completed: false,
19+
}
20+
```

questions/3-easy-omit/info.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
title: Omit<T, K>
2+
3+
author:
4+
name: Anthony Fu
5+
email: hi@antfu.me
6+
github: antfu
7+
8+
tags: union, built-in

0 commit comments

Comments
 (0)