タプル(固定長の配列)からユニオン型を作り出す
code:memo.ts
const suits1 = "spade", "heart", "diamond", "club" as const;
type Suit1 = typeof suits1number;
// ^? "spade" | "heart" | "diamond" | "club"
const suits2 = "spade", "heart" as const;
type Suit2 = typeof suits2number;
// ^? "spade" | "heart"
from https://zenn.dev/okunokentaro/articles/01gmpkp9gzgh3qmmpx9ey0d3x2#as-const
code:memo.ts
type TupleToUnion<T extends unknown[]> = Tnumber;
type Arr = "1", "2", "3";
const a: TupleToUnion<Arr>; // expected to be '1' | '2' | '3'
from https://ghaiklor.github.io/type-challenges-solutions/en/medium-tuple-to-union.html
#TypeScript