A union type lets a value or function parameter use one of several specified types. It fits limited, predictable cases such as a parameter accepting a string or number. section 3.8
Use union types when evaluating a function-parameter design:
- Choose a union when the allowed types are a fixed, known set and no relationship between input and output is required. section 3.8
- Account for type narrowing: unions can be less specific about return types and may require additional narrowing. section 3.8
- Prefer generics when the function must support open-ended types or preserve a strong input-output relationship; prefer unions when simplicity matters more than reusability. section 3.8












