QuizNot attempted
Conflicting intersections
1–4 to choose, Enter to submit
Show answer & explanation
Correct answer:
Astays an object type whoseidisnever;Breduces toneverentirely
- An intersection intersects the types of shared properties, so
A['id']isstring & number=never(no value ofAcan exist, but the type itself is kept) - when the clashing property is a literal-typed discriminant, TS 3.9+ reduces the whole object type to
never, as withB. - Not 'both become never': only discriminant clashes collapse the whole type.
- Not string | number: that would be a union, not an intersection.
- Not compile errors: conflicting intersections are legal
- they just can't be inhabited.