Can a literal array type be created in MST that is equivalent to
type Interval = ['1min', '5min']
;
Here's an example of code that results in an error:
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,
}),
})
The types.array()
method expects to have one argument, so is it even possible? Unfortunately, the MST documentation doesn't provide much clarity on this issue. MST Documentation