IT lexicon › Programming › Union type

Union type

Programming På svenska → Updated: 2026-05-24

A type that can be one of several: string | number | null.

TypeScript, Python (with | in 3.10+), Rust (as enum variants), Swift. Forces exhaustive checks in the compiler. A discriminated union = a union where each variant has a tag field — makes pattern matching safe. The heart of "type-safe state machines".

← Back to the lexicon