JavaScript & TypeScript

Union Type

/ˈjuːnjən taɪp/

Definition

A TypeScript type allowing a value to be one of several types — string | number | undefined.

Example in context

"type Status = 'pending' | 'active' | 'cancelled' — the compiler rejects any other string value."

Related terms

Practice this term

Master Union Type in context by working through exercises in the JavaScript & TypeScript module. You'll see the term used in real engineering scenarios with multiple-choice, fill-in-the-blank, and matching drills.