Omit Keys from an Object, Typed

Write the code, see it run, pass the checks.

The problem

  • medium
  • Code

Write omit(obj, keys): return a new object with every property of obj except the listed keys, leaving obj unchanged. Type it so the result has exactly the remaining properties (reading an omitted one is a type error), and so listing a key obj doesn't have is a type error, which catches typos like "passwd".

Your code must pass

  • Drops the listed keys
  • Leaves obj unchanged
  • Has no type errors
  • Returns the object without the omitted keys
  • An omitted property can't be read
  • Rejects a key the object doesn't have