Omit
提出詳細
type MyOmit<T, K extends keyof T> = { [Key in keyof T as Key extends K ? never : Key]: T[Key]; };
提出日時 | 2023-05-22 13:57:55 |
---|---|
問題 | Omit |
ユーザー | mrsekut |
ステータス | Accepted |
import type { Equal, Expect } from '@type-challenges/utils' type cases = [ Expect<Equal<Expected1, MyOmit<Todo, 'description'>>>, Expect<Equal<Expected2, MyOmit<Todo, 'description' | 'completed'>>>, ] // @ts-expect-error type error = MyOmit<Todo, 'description' | 'invalid'> interface Todo { title: string description: string completed: boolean } interface Expected1 { title: string completed: boolean } interface Expected2 { title: string }