TypeScript will sometimes decide that two types, if intersected, don't have any compatible values. This empty intersection is called never and means that you can't provide a value that fulfills both types:
type Bread = {
shape: "loafy"
};
type Car = {
shape: "carish"
};
// Contradiction1: Immediately resolved to 'never'
type Contradiction1 = Bread & Car;
However, this seems to work inconsistently. If the conflicting properties are not at the top level of the type, TypeScript misses it and doesn't behave the way I expect:
// Wrap the contradicting types
type Garage = { contents: Car };
type Breadbox = { contents: Bread };
// Contradiction2: Garage & Breadbox
// Expected: Should immediately reduce to never
type Contradiction2 = Garage & Breadbox;
Is this a bug? Why does TypeScript behave this way?