Skip to content

    ↑↓ move · ⏎ open · esc close

    Object shapes

    Omit

    Drops the named keys — and, unlike `Pick`, does not care whether they were ever there.

    What it is

    Not a primitive: `Omit` is `Pick<T, Exclude<keyof T, K>>`, which the definition on the right shows plainly. The constraint is `keyof any`, not `keyof T`, and that single difference is responsible for most of the bugs this type is involved in.

    Examples

    • Omit<{ a: string; b: number }, 'b'>
      { a: string; }
    • Omit<{ a: string }, 'typo'>
      { a: string; }

      No error, no effect. A misspelled key silently omits nothing, and the type still looks right.

    • Omit<{ a: string; b: number; c: boolean }, 'a' | 'b'>
      { c: boolean; }

    Each resolved type above was printed by TypeScript 5.9.3, not written by hand.

    What it does not do

    • It does not check the keys you pass. `Omit<User, "nmae">` compiles, removes nothing, and is the single most common silent bug in TypeScript codebases.
    • It does not distribute over unions, so omitting from `A | B` collapses to the keys they share before removing anything.

    Takeaway

    If you want the typo caught, write your own: `type StrictOmit<T, K extends keyof T> = Omit<T, K>`. The constraint is the entire fix.