Overview - Union vs intersection mental model
What is it?
Union and intersection are ways to combine types in TypeScript. A union type means a value can be one of several types. An intersection type means a value must have all the combined types at once. These help describe what kind of data your program can accept or produce.
Why it matters
Without union and intersection types, programs would be less flexible or safe. Union types let you accept multiple kinds of inputs without losing type safety. Intersection types let you combine features from different types to create richer objects. Without them, code would be more error-prone and harder to understand.
Where it fits
Learners should know basic TypeScript types and how to declare them. After this, they can learn about advanced type features like type guards, mapped types, and conditional types to write safer and more expressive code.