在写代码时 想根据对象或数组来生成一些常量类型。比如:
const obj = {
dev_server: 'http://dev_server/',
prod_server: 'https://prod_server/',
stage_server: 'https://stage_server/'
}
type KeyProps = ?
期待的keyProps
的是dev_server | prod_server | stage_server
和http://dev_server/ | https://prod_server/ | https://stage_server/
const arr = [
{label: 'dev', value: 'dev'},
{label: 'prod', value: 'prod'},
{label: 'stage', value: 'stage'},
]
type KeyProps = ?
期待的KeyProps
的是dev | prod | stage
应该怎么定义这几个的类型呢? 请论坛内大神指教指教~