typescript union values code example
Example 1: union value typescript
let myVar : string | number; //Variable with union type declaration
myVar = 100; //OK
myVar = 'Lokesh'; //OK
myVar = true; //Error - boolean not allowed
Example 2: union value typescript
let myVar : string | number; //myVar can store string and number types