Skip to content

Commit

Permalink
Avoid adding empty trailing comments to oneof unions
Browse files Browse the repository at this point in the history
  • Loading branch information
haines committed Nov 25, 2024
1 parent 37d3a39 commit d418fb8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 36 deletions.
21 changes: 7 additions & 14 deletions integration/oneof-unions-value/oneof.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 7 additions & 14 deletions integration/oneof-unions/oneof.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions integration/use-readonly-types/use-readonly-types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,9 @@ function generateOneofProperty(
maybeAddComment(options, fieldInfo, fieldComments);

const combinedComments = fieldComments.join("\n");
return code`| // \n ${combinedComments} { ${mbReadonly}$case: '${fieldName}', ${mbReadonly}${valueName}: ${typeName} }`;
return code`|${
combinedComments ? " // " : ""
}\n ${combinedComments} { ${mbReadonly}$case: '${fieldName}', ${mbReadonly}${valueName}: ${typeName} }`;
}),
);

Expand Down Expand Up @@ -1531,7 +1533,7 @@ function generateDecode(ctx: Context, fullName: string, messageDesc: DescriptorP

chunks.push(code`
const buf = reader.skip(tag & 7);
${unknownFieldsInitializerSnippet}
const list = message._unknownFields${maybeNonNullAssertion}[tag];
Expand Down

0 comments on commit d418fb8

Please sign in to comment.