Skip to content

.d.ts typescript definition doesn't match js with proto3 optional fields #1072

Closed
@mattnathan

Description

@mattnathan

Given a proto file like

syntax = "proto3";

message MyMessage {
  optional float my_prop = 1;
}

Running the generator with options --js_out=import_style=commonjs,binary:. --grpc-web_out=import_style=commonjs+dts,mode=grpcwebtext:. the generated _pb.js file correctly has the get, set, has, and clear methods for interacting with the property. The _pb.d.ts file, however, describes the property using the fallback enum representation with get, set, and a MyPropCase enum for describing the _NOT_SET and set semantics.

While I understand that this is technically correct for a language generator to describe the proto message in this way (that's how backwards compatibility is supported), this doesn't really work in this case as the .d.ts file is supposed to describe the .js file.

Anyway, sorry if this is reported elsewhere, I couldn't find anything when searching.

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