RMAG news

Simplifying Union Types and Arrays in TypeScript

When working with TypeScript, you might find yourself needing to define a union type and an array containing all of the possible values of that type. A common approach is to write something like this: type Taste = ‘しょうゆ‘ | ‘みそ‘ | ‘とんこつ‘; const tastes = [‘しょうゆ‘, ‘みそ‘, ‘とんこつ‘]; At first glance, this seems fine….