Property Type Conflicts in Intersections
What You'll Learn
You'll learn what happens when you intersect two types that have the same property name but incompatible types — and why the result is never.
The Core Problem
When you create an intersection type with &, TypeScript tries to merge all properties from both types. But what if both types have a property with the same name but incompatible types?
TypeScript resolves this by making that property's type the intersection of both types. If those types can't overlap (like string & number), the result is never — an impossible type.
Why This Happens
Think of intersections like a Venn diagram. When you intersect string & number, you're asking for a value that is simultaneously a string AND a number. No such value exists in JavaScript, so TypeScript uses never to represent this impossibility.
type A = {
id: string;
};
type B = {
id: number;
};
type Combined = A & B;
// Combined is { id: string & number }
// which simplifies to { id: never }
const obj: Combined = {
id: // ❌ No value can satisfy both string AND number!
};
The id property must be both a string and a number simultaneously — which is impossible.
When You'll See This
This commonly happens when:
- Accidentally intersecting similar types with different property types
- Merging types from different library versions
- Building complex type compositions without careful alignment
type Circle = { radius: number };
type Square = { radius: string }; // Oops, wrong type!
type Impossible = Circle & Square;
// { radius: never }
Key Takeaway: When intersecting types with the same property name but incompatible types, that property becomes never because no value can satisfy both type constraints simultaneously.