Union type ( | )
A variable being able to take multiple types.
Syntax
let x: type1 | type2;
Description
With | (or), you state that a variable can be one of several types.
Example
Loading editor…
Expected output
42 A42
When to use?
Fields that can be both numbers and strings (id, input value).