A brief introduction to TypeScript's Union (|) and Intersection (&) types. Union types allow a value to be one of several types, with the compiler only exposing properties common to all members. Intersection types combine multiple types into one, merging all their properties. Short code examples illustrate both concepts.

2m read timeFrom playfulprogramming.com
Post cover image
Table of contents
Union Copy link Link copied!Intersection Copy link Link copied!

Sort: