English Reference

Word

union type

Definition

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.

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

Examples

simple

“The programmer used a union type to handle both strings and numbers.”

contextual

“When writing the function, she defined a union type so the input could be either a single user ID or an array of IDs.”

complex

“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

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

Etymology

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.

Domain

Programming

This entry

Exam level
CambridgeCambridgeCambridge English QualificationsThe exam suite from Cambridge University Press & Assessment, from A1 Movers up to C2 Proficiency. The benchmark names double as CEFR labels.C2 ProficiencyIELTSIELTSInternational English Language Testing SystemThe 0–9 band test co-owned by the British Council, IDP, and Cambridge. Used for university entry, work, and migration.8.5–9.0TOEFL iBTTOEFL iBTTest of English as a Foreign Language, Internet-Based TestETS's academic English test, the standard route for US university admissions. Scored 0–120, with a 1–6 scale since 2026.1–6 scale: 6.0114–120
Level
C2 · Proficiency
Updated

QR code

englishreference.com/q/union-type

English Reference