π Typescript/type-challenges
[TS] type-challenges : 4. Pick
μ λ¬
2023. 6. 28. 23:26
λ°μν
λ¬Έμ
T
μμ K
νλ‘νΌν°λ§ μ νν΄ μλ‘μ΄ μ€λΈμ νΈ νμ
μ λ§λλ λ΄μ₯ μ λ€λ¦ Pick<T, K>
μ μ΄λ₯Ό μ¬μ©νμ§ μκ³ κ΅¬ννμΈμ.
μμ:
interface Todo {
title: string
description: string
completed: boolean
}
type TodoPreview = MyPick<Todo, 'title' | 'completed'>
const todo: TodoPreview = {
title: 'Clean room',
completed: false,
}
νμ΄
type MyPick<T, K extends keyof T> = {[key in K]: T[key]};
μΆμ²
https://github.com/type-challenges/type-challenges/blob/main/questions/00004-easy-pick/README.ko.md
GitHub - type-challenges/type-challenges: Collection of TypeScript type challenges with online judge
Collection of TypeScript type challenges with online judge - GitHub - type-challenges/type-challenges: Collection of TypeScript type challenges with online judge
github.com
λ°μν