Skip to content

fix repeated msg deserialization #112

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

Merged
merged 2 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/.

## 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 <[email protected]>",
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