Skip to content

Option to Generate enum for UPPER_CASE #2366

@harish1094

Description

@harish1094

How can I configure the generation of an enum with UPPER_CASE keys?

"TaskType": {
                "title": "TaskType",
                "enum": [
                    "test_type_1",
                    "test_type_2",
                    "test_type_3", 
                    "invalid_type",
                ],
                "type": "string",
                "description": "An enumeration."
            }

The generated out is :

export type TaskType =
    (typeof TaskType)[keyof typeof TaskType];

export const TaskType = {
    test_type_1: "test_type_1",
    test_type_2: "test_type_2",
    test_type_3: "test_type_3",
    invalid: "invalid"
} as const;

Expected enum:

export type TaskType =
    (typeof TaskType)[keyof typeof TaskType];

export const TaskType = {
    TEST_TYPE_1: "test_type_1",
    TEST_TYPE_2: "test_type_2",
    TEST_TYPE_3: "test_type_3",
    INVALID: "invalid"
} as const;

Metadata

Metadata

Assignees

No one assigned

    Labels

    workaroundA workaround has been provided

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions