Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
p-jahn opened this issue Feb 4, 2021 · 1 comment

Comments

@p-jahn
Copy link

p-jahn commented Feb 4, 2021

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

@agreatfool
Copy link
Owner

Fixed with version v5.1.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants