Skip to content

Commit

Permalink
fix repeated msg deserialization (#112)
Browse files Browse the repository at this point in the history
* fix repeated msg deserialization

fixes #109

* Update CHANGELOG.md

Co-authored-by: Tate <tate@transcriptic.com>
  • Loading branch information
tatethurston and Tate authored Jan 28, 2022
1 parent ae12262 commit 949503b
Show file tree
Hide file tree
Showing 6 changed files with 252 additions and 465 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.0.43

- Fix repeated message deserialization by @tatethurston in https://github.com/tatethurston/TwirpScript/pull/112.

## v0.0.42

- More compact code generation for empty messages by @tatethurston in https://github.com/tatethurston/TwirpScript/pull/101.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "twirpscript",
"version": "0.0.42",
"version": "0.0.43",
"description": "A protobuf RPC framework for JavaScript and TypeScript",
"license": "MIT",
"author": "Tate Thurston <tatethurston@gmail.com>",
Expand Down Expand Up @@ -31,7 +31,7 @@
"lint:fix": "prettier --write . && prettier-package-json --write '{,example/}package.json'",
"lint:package:fix": "prettier-package-json --write ./package.json",
"prepack": "yarn build",
"regen": "yarn test -u && yarn examples:check && (cd clientcompat && yarn twirpscript)",
"regen": "(cd src/test-serialization && yarn twirpscript) && yarn test -u && yarn examples:check && (cd clientcompat && yarn twirpscript)",
"test": "yarn jest src/*",
"test:ci": "yarn test --coverage",
"typecheck": "yarn tsc --noEmit"
Expand Down
6 changes: 3 additions & 3 deletions src/autogenerate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ function writeSerializers(types: ProtoTypes[], isTopLevel = true): string {
});`;
} else if (field.read === "readMessage") {
if (field.repeated) {
res += `msg.${field.name}.push(
reader.readMessage(${field.tsType}.initialize(), ${field.tsType}._readMessage));
`;
res += `const m = ${field.tsType}.initialize();`;
res += `reader.readMessage(m, ${field.tsType}._readMessage);`;
res += `msg.${field.name}.push(m);`;
} else {
res += `
reader.readMessage(msg.${field.name}, ${field.tsType}._readMessage);
Expand Down
Loading

0 comments on commit 949503b

Please sign in to comment.