3 - Omit

Author: VarunMendreCreated Sep 14, 2026Updated Sep 14, 2026
Labelsanswer3en
/**
 * Removes keys K from type T, returning a new object type with only the remaining properties.
 * Uses TS 4.1 key remapping: the `as` clause filters keys by mapping them to `never`
 * (which drops them from the result) when they match K; otherwise, it keeps the original key.
 */
type MyOmit<T, K extends keyof T> = {
  [P in keyof T as P extends K ? never : P] : T[P]
}   

Source: type-challenges/type-challenges