Skip to content

Improve type representation for open enums #1216

@timostamm

Description

@timostamm

Protobuf has closed and open enums. A closed enum (proto2) only accepts declared values, while an open enum (proto3) also accepts other values. protoc-gen-es generates TypeScript enums, which are always closed since version 5.0.

This means that generated types do not match the semantics for open Protobuf enums. There is no indication that an enum field could contain a value that isn't one of the TypeScript enum values, and additional checks might even be flagged as unnecessary or incorrect by the compiler.

We should investigate how to improve the generated enum types or fields to properly reflect open enum semantics.

Context:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions