TypeScriptSyntax
Union Type
Code example
let id: string | number;Allows a value to be one of several types.
In TypeScript, union type: allows a value to be one of several types — let id: string | number;
let id: string | number;let id: string | number;Allows a value to be one of several types.
Use let id: string | number;.
Use this pattern: let id: string | number;
Yes. Use Copy code and adapt the example to your program.
No. The language syntax is the same across operating systems.