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

Trailing underscore, toObject produces object that does not conform to AsObject #309

Open
robdodson opened this issue Aug 4, 2022 · 0 comments

Comments

@robdodson
Copy link

robdodson commented Aug 4, 2022

Versions of relevant software used

  • libprotoc 3.19.4
  • ts-protoc-gen 0.15.0

What happened
I think this may be related to #182

We're using Goa to generate our .proto files. If you name a field message in Goa, it will rename it to message_ in the .proto.

note.proto

message Note {
	string message_ = 1;
}

If you then process this proto using ts-protoc-gen, the toObject method does not conform to AsObject:

note.d.ts

export namespace Note {
  export type AsObject = {
    message_: string,
  }
}

note_pb.js

proto.voc_admin.Note.toObject = function(includeInstance, msg) {
  var f, obj = {
    message: jspb.Message.getFieldWithDefault(msg, 1, "")
  };
  
  // ...
};

What you expected to happen
The property should be named message_ in the object returned from note_pb.js.

How to reproduce it (as minimally and precisely as possible):
Create a field with a trailing underscore in your .proto file.

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

1 participant