미리 Union타입을 만들어서 사용하는 방법과 자료구조에서 Union 타입을 추출해는 방법이 있다.
type Fruit = "apple" | "orange" | "lemon"| "melon"
const myFruit: Fruit = "kiwi" // Type '"kiwi"' is not assignable to type 'Fruit'
const yourFruit: Fruit = "apple"
const fruits = ["apple", "orange", "lemon"] as const
type Fruits = typeof fruits[number]
const countryCurrency = {
KOREA : "KRW",
USA : "USD",
CANADA : "CAD",
} as const;
type Country = keyof typeof countryCurrency
type Currency = (typeof countryCurrency)[keyof typeof countryCurrency]