Skip to content

CodeNot attempted

Type challenge: MyOmit

Difficulty: medium

Implement MyOmit<T, K> without Omit, Pick or Exclude. Hint: key remapping in a mapped type (as), where mapping a key to never drops it.

Show reference solution
// Key remapping with `as`: mapping a key to `never` drops it.
export type MyOmit<T, K extends keyof any> = { [P in keyof T as P extends K ? never : P]: T[P] };
Loading editor…