Skip to content

Commit aaf3517

Browse files
committed
Avoid adding empty trailing comments to oneof unions
stephenh/ts-proto#1140 Signed-off-by: Andrew Haines <[email protected]>
1 parent b76defd commit aaf3517

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,10 @@
7272
"tsx": "4.19.2",
7373
"typescript": "5.6.3",
7474
"typescript-eslint": "8.15.0"
75+
},
76+
"pnpm": {
77+
"patchedDependencies": {
78+
79+
}
7580
}
7681
}

patches/[email protected]

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/build/src/main.js b/build/src/main.js
2+
index 3e03249d11bae4b1ccc9000e0f4e41f1e4393f26..a6e519f26db63304ab4f29781261d2736d986382 100644
3+
--- a/build/src/main.js
4+
+++ b/build/src/main.js
5+
@@ -851,7 +851,7 @@ function generateOneofProperty(ctx, messageDesc, oneofIndex, sourceInfo) {
6+
let fieldComments = [];
7+
(0, utils_1.maybeAddComment)(options, fieldInfo, fieldComments);
8+
const combinedComments = fieldComments.join("\n");
9+
- return (0, ts_poet_1.code) `| // \n ${combinedComments} { ${mbReadonly}$case: '${fieldName}', ${mbReadonly}${valueName}: ${typeName} }`;
10+
+ return (0, ts_poet_1.code) `|${combinedComments ? " // " : ""}\n ${combinedComments} { ${mbReadonly}$case: '${fieldName}', ${mbReadonly}${valueName}: ${typeName} }`;
11+
}));
12+
const name = (0, case_1.maybeSnakeToCamel)(messageDesc.oneofDecl[oneofIndex].name, options);
13+
return (0, ts_poet_1.joinCode)([...outerComments, (0, ts_poet_1.code) `${mbReadonly}${name}?:`, unionType, (0, ts_poet_1.code) `| ${(0, utils_1.nullOrUndefined)(options)},`], {
14+
@@ -1155,7 +1155,7 @@ function generateDecode(ctx, fullName, messageDesc) {
15+
}
16+
chunks.push((0, ts_poet_1.code) `
17+
const buf = reader.skip(tag & 7);
18+
-
19+
+
20+
${unknownFieldsInitializerSnippet}
21+
const list = message._unknownFields${maybeNonNullAssertion}[tag];
22+

pnpm-lock.yaml

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)