Open
Description
I am curious if that's possible somehow? You see, I am using library mobx-state-tree which is also checked at runtime, but currently, it's impossible to use Typescript types for modeling.
type State = 'Unknown' | 'Online' | 'Offline'
const Model = types.model({
connState: types.enumeration(['Unknown', 'Online', 'Offline'])
})
The first step should be probably to support Symbol.iterator and then I can do this.
const State = Union(
Literal('Unknown'),
Literal('Online'),
Literal('Offline')
)
const Model = types.model({
connState: types.enumeration(Array.from(State))
})
However, that's not enough since it would give an array of Literal objects. I am not how to proceed there to keep the ease of use. Perhaps some custom method like State.toArray()
could be more feasible?