Skip to content

Provide string enum option #26

Description

@rurutia

Avro enums are only compiled to numeric enums

export enum colorTypes {
    red,
    blue,
    green,
}

It does not work for our scenario when having java consumer expecting string value from the same schema. It needs to be compiled to string enums like

export enum colorTypes {
    red = "red",
    blue = "blue",
    green = "green",
}

actually, I think by default typescript enum should always be constant-initialized with a string literal fpor avro serde as suggested by https://www.typescriptlang.org/docs/handbook/enums.html

String enums have the benefit that they “serialize” well. In other words, if you were debugging and had to read the runtime value of a numeric enum, the value is often opaque - it doesn’t convey any useful meaning on its own (though reverse mapping can often help), string enums allow you to give a meaningful and readable value when your code runs, independent of the name of the enum member itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions