Skip to content

pbjs generates wrong code by replacing 'w' with 'writer' #663

@fabian-gehrs

Description

@fabian-gehrs

protobuf.js version: 6.6.1

I have the following ProtoBuf message:

message Quaternion {
  float x = 1;
  float y = 2;
  float z = 3;
  float w = 4;
}

If i use on this message

pbjs -t static-module -w commonjs

the generated class has a property 'w', but all methods replaced the 'w' with 'writer' as you can see in the following example:

Quaternion.encode = function encode(message, writer) {
    if (!writer)
        writer = $Writer.create();
    if (message.x !== undefined && message.hasOwnProperty("x"))
        writer.uint32(/* id 1, wireType 5 =*/13).float(message.x);
    if (message.y !== undefined && message.hasOwnProperty("y"))
        writer.uint32(/* id 2, wireType 5 =*/21).float(message.y);
    if (message.z !== undefined && message.hasOwnProperty("z"))
        writer.uint32(/* id 3, wireType 5 =*/29).float(message.z);
    if (message.writer !== undefined && message.hasOwnProperty("writer"))
        writer.uint32(/* id 4, wireType 5 =*/37).float(message.writer);
    return writer;
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions