是否可以在 MST 中创建文字数组类型?它应该相当于
type Interval = ['1min', '5min']
;
这是引发错误的代码示例
type Interval = '1min' | '5min';
export interface AppStore {
config: {
intervals: ['1min', '5min']
},
search: {
symbol: string;
interval: string;
dataTypes: string[];
}
}
const appStore = types
.model<AppStore>('appStore', {
config: types.model({
intervals: types.array(
types.literal<Interval>('1min'),
types.literal<Interval>('5min')
),
}),
search: types.model({
dataTypes: types.array( types.string ),
interval: types.union(
types.literal<Interval>('1min'),
types.literal<Interval>('5min')
),
symbol: types.string,
}),
})
期望有一个论点,types.array()
所以它甚至可能吗?MST 文档不走运https://github.com/mobxjs/mobx-state-tree#types-overview