Skip to content

specific message field names lead to conflicts with base class in getter/setter #84

@p-jahn

Description

@p-jahn

If a proto definition contains a message like

message SomeMessage {
  string extension = 1;
}

then the generated code contains something like

export class SomeMessage extends jspb.Message {
    // ...
    getExtension(): string;
    setExtension(value: string): SomeMessage;
    // ...

which are (invalid) implementations of the base methods

export abstract class Message {
    // ...
    getExtension<T>(fieldInfo: ExtensionFieldInfo<T>): T;
    setExtension<T>(fieldInfo: ExtensionFieldInfo<T>, value: T): void;
    // ...

The JS generator works around affected field names Extension and JsPbMessageId this by adding a $ to the getter/setter name: https://github.com/protocolbuffers/protobuf/blob/cf28f28347d65e352f429263500f982ae3e51aed/src/google/protobuf/compiler/js/js_generator.cc#L533-L536

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions