We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
For some reason numbers are not allowed in enumerations:
const ordersRequest = types.model({ paymentPeriod: types.optional(types.array(types.enumeration('PaymentPeriod', [15, 30])), [15]), })
i.e. for a type like: (15 | 30)[].
(15 | 30)[]
As far as I understand, I have to use types.union for this:
types.union
const ordersRequest = types.model({ paymentPeriod: types.optional(types.array(types.union(types.literal(15), types.literal(30))), [15]), })
Can numbers be added to enumerations?
The text was updated successfully, but these errors were encountered:
I can't see why we shouldn't support that! :)
But it is indeed always forced into a string enumeration now because of this line:
mobx-state-tree/src/types/utility-types/enumeration.ts
Line 44 in ab45ead
I did some digging and found that it's been that way since its introduction, with no explanation as to why we did that: #263
My gut is saying there's no particular reason why this was done, but we'll have to investigate it.
Sorry, something went wrong.
No branches or pull requests
For some reason numbers are not allowed in enumerations:
i.e. for a type like:
(15 | 30)[]
.As far as I understand, I have to use
types.union
for this:Can numbers be added to enumerations?
The text was updated successfully, but these errors were encountered: