One of several types
An ID might be a number or a string. A setting might be a value or not set. A union type says "this OR that", with a | between the options.
Writing and using unions
function format(id: number | string): string {
return "#" + id;
}
format(42);
format("A-17");
format(true);
function len(id: number | string) {
return id.length;
}