Naming of TypeScript’s union and intersection types

Here’s another way to think about it. Consider four sets: Blue things, red things, big things, and small things.

If you intersect the set of all blue things and all small things, you end up with the union of the properties — everything in the set has both the blue property and the small property.

But if you took the union of blue small things and red small things, only the smallness property is universal in the resulting set. Intersecting “blue small” with “red small” produces “small”.

In other words, taking the union of the domain of values produces an intersected set of properties, and vice versa.

In image form:
enter image description here

Leave a Comment