-
Notifications
You must be signed in to change notification settings - Fork 172
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
Change return type of generated setters to the message type #281
base: master
Are you sure you want to change the base?
Conversation
@@ -184,12 +184,12 @@ export function printMessage(fileName: string, exportMap: ExportMap, messageDesc | |||
printer.printIndentedLn(`get${withUppercase}List(): Array<Uint8Array | string>;`); | |||
printer.printIndentedLn(`get${withUppercase}List_asU8(): Array<Uint8Array>;`); | |||
printer.printIndentedLn(`get${withUppercase}List_asB64(): Array<string>;`); | |||
printer.printIndentedLn(`set${withUppercase}List(value: Array<Uint8Array | string>): void;`); | |||
printer.printIndentedLn(`set${withUppercase}List(value: Array<Uint8Array | string>): ${messageName};`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the Protoc docs:
addFoo(): Appends a value of foo to the end of the list of foos that was in the message. Returns the outer message for chaining only if the added value was a primitive. For added messages, returns the message that was added (b/138079947).
https://developers.google.com/protocol-buffers/docs/reference/javascript-generated
My understanding is this means the return type of setInternalChildMessage
for example should be the child message type, and not the parent message type.
// Wrong
setInternalChildMessage(value?: OneOfMessage.InternalChildMessage): OneOfMessage;
// Correct
setInternalChildMessage(value?: OneOfMessage.InternalChildMessage): OneOfMessage.InternalChildMessage;
Can you add some test cases to verify this?
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: MarcusLongmuir The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Just ran into this issue trying to update definitions. It looks like this PR is approved - any reason it can't be checked in and pushed out in a new version? Anything I can do to help? |
Bumping this PR... is there any reason this can't be merged? |
bump |
Changes
npm run generate
to regenerate example proto generated codeVerification
Added unit tests for chained setter methods.