QuizNot attempted
Mutually exclusive props need never
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
- Yes: for a union, a property is only "excess" if no member declares it; add
isNegative?: never; zero?: neveretc. to forbid mixing
- The literal is assignable to the first member structurally, and excess-property checking against a union only flags keys that appear in none of the members, so
zeroslips through - giving each member the other flags as
?: nevermakes any second flag a type error, which is how you encode 'exactly one of'. - Not 'must match exactly one member': unions are not exclusive.
- Not 'zero is an excess property':
zeroexists on a member, so it is not excess. - Not 'true literals would fix it': the flag type is irrelevant
- the missing
neverkeys are the problem.