union type
compound.compound. a way to store data that can hold one of several different types of information. It is like a box that can hold either a number or a word, but only one at a time.
compound. a data type that allows a single memory location to store values of different types at different times. In programming, it represents a value that could be any one of several specified types.
The programmer used a union type to handle both strings and numbers.
When writing the function, she defined a union type so the input could be either a single user ID or an array of IDs.
In TypeScript, a union type is declared using the pipe symbol to indicate that a variable may hold any of the constituent types defined in the set.
A compound term formed from the mathematical concept of a union, denoting the set containing all elements of the given collections, and the computational sense of type. The nomenclature reflects the set-theoretic foundations of early programming language design.
Etymology adapted from Wiktionary, available under CC BY-SA 4.0.
Commonly used in computer science and statically-typed programming languages like C, C++, and TypeScript.
Last updated July 22, 2026