问题描述
Implement the built-in Pick
generic without using it. Constructs a type by picking the set of properties K from T
For example:
interface Todo {
title: string
description: string
completed: boolean
}
type TodoPreview = MyPick
const todo: TodoPreview = {
title: 'Clean room',
completed: false,
}
Solution
type MyPick = {
[P in K]: T[P]
}