TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
| operator in TypeScript denotes a Union Type, constructing a new type that represents a value capable of satisfying at least one of several constituent types. In type theory, it functions as an inclusive logical disjunction (OR) at the type level. Because TypeScript utilizes structural typing, a union does not enforce mutual exclusivity (XOR); a value can satisfy multiple constituent types simultaneously. The operator expands the set of permissible values for a given binding while strictly limiting the immediately accessible properties to the intersection of the constituent types’ members.
A | B, the compiler only permits access to members (properties or methods) that are common to both A and B. Because unions are inclusive, an object containing properties from multiple constituent types is perfectly assignable to the union.
typeof, instanceof, the in operator, or custom type predicates).
| operator is frequently applied to literal types (string, number, or boolean literals) to define a finite, discrete set of exact permissible values, effectively creating an enumeration at the type level.
| operator is the discriminated union. This occurs when all constituent types in a union share a common, literal-typed property (the discriminant). The compiler uses this discriminant to perform exhaustive type checking and precise narrowing across the union.
Master TypeScript with Deep Grasping Methodology!Learn More





