Hint
Intersection types require ALL properties from all intersected types. When the same property appears with incompatible types, TypeScript resolves it to never — making it unusable. At runtime, object spread takes the last value.
// Simulate TypeScript intersection type A & B
// An intersection must have ALL properties from both types
function merge(a, b) {
return { ...a, ...b };
}
// Serializable = { serialize(): string }
// Loggable = { log(): void }
// Combined = Serializable & Loggable = must have both
const serializable = { serialize: () => '{"name":"Alice"}' };
const loggable = { log: () => console.log('logged') };
const combined = merge(serializable, loggable);
// combined has ALL properties from both
console.log(typeof combined.serialize);
console.log(typeof combined.log);
console.log(combined.serialize());
// Check what happens when same key appears (last writer wins at runtime)
const conflicting = merge({ id: 'string-id' }, { id: 42 });
console.log(typeof conflicting.id); // intersection: string & number = never (TS)
// but at runtime: last value winsfunction
function
{"name":"Alice"}
numberExplanation: merged object has all properties from both sources. When the same key conflicts, runtime spread takes the last value (42, a number). TypeScript would type this as never (string & number = never).
Key Insight: Intersection types require ALL properties from all intersected types. When the same property appears with incompatible types, TypeScript resolves it to never — making it unusable. At runtime, object spread takes the last value.