Skip to content

Enumeration number problem #2243

@OnkelTem

Description

@OnkelTem

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)[].

As far as I understand, I have to use types.union for this:

const ordersRequest = types.model({
paymentPeriod: types.optional(types.array(types.union(types.literal(15), types.literal(30))), [15]),
})

Can numbers be added to enumerations?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementPossible enhancementhelp/PR welcomeHelp/Pull request from contributors to fix the issue is welcomelevel: easy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions