TypeScript · Middle · Question 51 of 75
Why does Omit<Circle | Square, 'id'> lose the discriminated union?
type DistributiveOmit<T, K extends PropertyKey> = T extends any ? Omit<T, K> : never;- ✓Correct answer:
Omituseskeyofof the whole union (only common keys); a distributive version applies it to each member - 2
Omitdoesn't work with unions at all - 3It removes
idonly from the first member
Explanation
keyof (A | B) contains only shared keys, so member-specific properties disappear. The conditional type distributes over the union.