Skip to content

Commit 102a00a

Browse files
authored
fix: only parse arguments from first line of tag comment (#1650)
1 parent d541c9b commit 102a00a

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/transformation/utils/annotations.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ export function getFileAnnotations(sourceFile: ts.SourceFile): AnnotationsMap {
105105
function getTagArgsFromComment(tag: ts.JSDocTag): string[] {
106106
if (tag.comment) {
107107
if (typeof tag.comment === "string") {
108-
return tag.comment.split(" ");
108+
const firstLine = tag.comment.split("\n")[0];
109+
return firstLine.trim().split(" ");
109110
} else {
110111
return tag.comment.map(part => part.text);
111112
}

test/translation/__snapshots__/transformation.spec.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ escapedCharsInTemplateString = "\\\\ \\0 \\b \\t \\n \\v \\f \\" ' \`"
3636
nonEmptyTemplateString = ("Level 0: \\n\\t " .. ("Level 1: \\n\\t\\t " .. ("Level 3: \\n\\t\\t\\t " .. "Last level \\n --") .. " \\n --") .. " \\n --") .. " \\n --""
3737
`;
3838

39+
exports[`Transformation (customNameWithExtraComment) 1`] = `"TestNamespace.pass()"`;
40+
3941
exports[`Transformation (customNameWithNoSelf) 1`] = `"TestNamespace.pass()"`;
4042

4143
exports[`Transformation (exportStatement) 1`] = `
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/** @noSelf */
2+
declare namespace TestNamespace {
3+
/**
4+
* @customName pass
5+
* The first word should not be included.
6+
**/
7+
function fail(): void;
8+
}
9+
10+
TestNamespace.fail();

0 commit comments

Comments
 (0)