DEV Community

Discussion on: The meaning of union and intersection types

Collapse
anduser96 profile image
Andrei Gatej

I think I finally understood it!

So it’s typescript’s magic that translates a union that resulted from a mathematical point of view into a single type that all the other types are assignable to.

So, without typescript, I’d get { { xyz, foo }, { xyz, bar } }, but after typescript weighs in, the resulted type will only be { xyz: string }.

I hope I got it right.

Thank you!

Thread Thread
miloszpp profile image
Milosz Piechocki Author

Yeah, I think you've got it right :)