If we have a union type like below:
let a: number | string;
let b: number | string;
It is difficult to repeat number | string
every time. Type aliases makes this easy.
type numstr = number | string;
After declaring our custom type, we can use it as below:
let a: numstr;
let b: numstr;