Skip to content

Map fields generated by protoc fail with google-protobuf v4 #249

@andreagasparin

Description

@andreagasparin

When generating JavaScript files from .proto using protoc (tested with version 32.1), the code for map fields calls serializeBinary() on jspb.Map instances. In google-protobuf@4.0.0, jspb.Map.prototype.serializeBinary no longer exists, causing runtime errors: "TypeError: f.serializeBinary is not a function".

I have a proto file that contains an element of type "map":
message TemplateEntity {
....
map<string, TemplateProperty> properties = 10;

message TemplateProperty {
...
}

In the generated file "..._pb.js" I see this code which seems incompatible with version 4:
...
f = message.getPropertiesMap(true);
if (f && f.getLength() > 0) {
f.serializeBinary(10, writer, jspb.BinaryWriter.prototype.writeString, jspb.BinaryWriter.prototype.writeMessage, proto.template.metadata.TemplateProperty.serializeBinaryToWriter);
}
...

Metadata

Metadata

Assignees

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