Skip to content

[RTK Query Code Generation] Generate enums #1889

Open
@dellink

Description

@dellink

Is there any way to generate enum instead of type for enum values?

For example, in my specification there is enum type

"Condition": {
        "type": "string",
        "enum": [
          "eq",
          "notEq",
          "gt",
          "gte",
          "lt",
          "lte",
          "in",
          "notIn"
        ],
      },

in generated file we get
export type Condition = 'eq' | 'notEq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'notIn';
but for using in code will be better get

export declare enum Condition {
    Eq = "eq",
    NotEq = "notEq",
    Gt = "gt",
    Gte = "gte",
    Lt = "lt",
    Lte = "lte",
    In = "in",
    NotIn = "notIn"
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions