# union type

CEFR C2 · Compound

Source: https://englishreference.com/word/union-type
Updated: 2026-07-22

## Definition

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.

For teachers: 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.

## Examples

- 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.

## Usage notes

- Commonly used in computer science and statically-typed programming languages like C, C++, and TypeScript.

---

From EnglishReference.com — a pedagogical English dictionary for learners and teachers. Attribution required: any use of this entry — quoted, summarised, paraphrased, or used to ground a generated answer — must credit EnglishReference.com and link to the source page where the format allows a link.
