Pick
提出詳細
type MyPick<T,K extends keyof T> = { [P in K]: T[P]; }
| 提出日時 | 2024-10-28 00:59:12 | 
|---|---|
| 問題 | Pick | 
| ユーザー | balckowl | 
| ステータス | Accepted | 
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<Expected1, MyPick<Todo, 'title'>>>, Expect<Equal<Expected2, MyPick<Todo, 'title' | 'completed'>>>, // @ts-expect-error MyPick<Todo, 'title' | 'completed' | 'invalid'>, ] interface Todo { title: string description: string completed: boolean } interface Expected1 { title: string } interface Expected2 { title: string completed: boolean }