TypeScript union type:
TypeScript Union Type provides the facility to combine one or two types for a variable. The pipe symbol (|) is used to combine the two or more data types.
Syntax:
var varName: dataType1|dataType2|dataType3
Example:
function unionTest(value:string|number):void{ console.log(value); } unionTest("Jai"); unionTest(123);