Change return type of generated setters to the message type#281
Change return type of generated setters to the message type#281craigatron wants to merge 4 commits intoimprobable-eng:masterfrom
Conversation
| 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.
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 DetailsNeeds 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 generateto regenerate example proto generated codeVerification
Added unit tests for chained setter methods.