[typescript]type union

Tue Feb 11

typescript

Author:Noritaka

Astro
let unionType: number | string = 10;
let unionTypes: (number | string)[] = [21, 'hello'];

unionType = 20;
unionType = 'hello';

typescript