TypeScript常用类型工具包

推导所有Object的可选值

1
2
3
4
5
const Fruits = {
APPLE = 'apple',
ORANGE = 'orange'
}
type Fruits = typeof Fruits[keyof typeof Fruits]; // apple, orange