Skip to content

QuizNot attempted

Conflicting intersections

What do A and B reduce to?
type A = { id: string } & { id: number };
type B = { kind: 'a'; x: number } & { kind: 'b' };
1–4 to choose, Enter to submit
Show answer & explanation

Correct answer:

  • A stays an object type whose id is never; B reduces to never entirely
  • An intersection intersects the types of shared properties, so A['id'] is string & number = never (no value of A can 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 with B.
  • 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.