Loading…
Loading…
Discover why TypeScript intersection types fail when treated as simple object merging. Local engineering teams in Johannesburg are catching these silent bugs early.

When Thabo Mokoena, a senior architect at a major Johannesburg fintech, pushed a routine schema update last October, his test suite passed cleanly. Within hours of deployment, production logs in Cape Town threw unhandled runtime type errors. The culprit wasn't a missing null check or an async race condition. It was an intersection type that promised one reality while compiler math delivered another. Across South African engineering teams, developers are discovering that TypeScript intersection types rarely behave the way object-oriented intuition suggests.
TypeScript adoption exploded across the Silicon Cape and Sandton technology corridors around 2018. Engineering leads migrating legacy JavaScript codebases naturally gravitated toward the ampersand operator. Writing type AdminUser = User & Permissions felt identical to object spreading or inheritance. Teams adopted this syntax because it kept codebases concise without requiring verbose interfaces or class hierarchies.
Early adoption rewarded this mental model because simple object shapes combined without friction. Developers wrote shared types for API payloads and Redux stores using basic intersections. The syntax looked clean in pull requests, and the compiler raised zero objections. Yet this honeymoon phase masked a fundamental mismatch between developer expectations and set theory.
Trouble began when codebases scaled beyond basic property unions into complex conditional types. By 2022, teams noticed peculiar bugs where properties mysteriously typed as never caused compiler blindness. Intersections do not merge object keys like Object.assign() or the spread operator. They enforce set intersections. If an API response defines id: string in type A and id: number in type B, the intersection creates id: string & number, which evaluates directly to never.
📌 Key Point: TypeScript does not merge overlapping property types during intersection; it intersects them, instantly turning conflicting primitives into the never type without a warning flag.
South African development squads running code reviews missed these silent failures because the TypeScript compiler successfully compiled the code. Type definitions expanded into sprawling, unreadable monstrosities. Engineers spent hours debugging runtime anomalies caused by impossible states that the compiler swore were valid. The tools built to catch bugs were actively shielding them from the root cause.
"We treated type intersections like a visual shorthand for merging objects, ignoring the underlying mathematical reality until our staging servers crashed on a Friday afternoon." — Kirsty van der Merwe, Lead Engineer at a Stellenbosch health-tech startup.
Local engineering groups are now abandoning casual property intersections in favor of explicit composition patterns. Teams are adopting branded types, mapped types, and helper utilities like Omit and Pick to manage component shapes safely. Rather than writing A & B, modern architecture guidelines mandate explicit interface extension or conditional type guards that validate property compatibility at author time. Refactoring thousands of lines of legacy types requires careful planning, but engineering leads report dramatic drops in production anomalies once strict boundaries are established.
Here are the core rules local teams now enforce:
Will South African engineering culture fully transition away from naive type merging toward rigorous set-theoretic design before the next scaling wave hits? As codebases grow more complex and AI-generated code floods repositories, understanding the exact mathematical boundaries of our types becomes non-negotiable. The compiler only knows what we teach it to verify.
Intersection types operate on set theory rather than object merging, meaning conflicting properties must satisfy both types simultaneously.
Share this article
Found this useful? Share it with your friends and followers.
Rate this article
Leave a comment
Related topics
You might also like
Handpicked stories for you

Local Delhi engineering teams rushing to adopt Next.js v4 are running into a silent performance wall. Here is why default AVIF rendering breaks production pipelines.





Enjoy this article?
Get fresh stories delivered to your inbox every morning.