Skip to content

Commit

Permalink
Fix duplicate visit of param tag comments (#44443)
Browse files Browse the repository at this point in the history
Fixes #44422
  • Loading branch information
sandersn committed Jun 4, 2021
1 parent b26f77a commit 8e1bf08
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/compiler/parser.ts
Expand Up @@ -500,8 +500,8 @@ namespace ts {
visitNode(cbNode, (node as JSDocPropertyLikeTag).typeExpression) ||
(typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray<JSDocComment> | undefined))
: visitNode(cbNode, (node as JSDocPropertyLikeTag).typeExpression) ||
visitNode(cbNode, (node as JSDocPropertyLikeTag).name)) ||
(typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray<JSDocComment> | undefined));
visitNode(cbNode, (node as JSDocPropertyLikeTag).name) ||
(typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray<JSDocComment> | undefined)));
case SyntaxKind.JSDocAuthorTag:
return visitNode(cbNode, (node as JSDocTag).tagName) ||
(typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray<JSDocComment> | undefined));
Expand Down
22 changes: 20 additions & 2 deletions src/testRunner/unittests/publicApi.ts
Expand Up @@ -150,6 +150,24 @@ describe("unittests:: Public APIs:: validateLocaleAndSetLanguage", () => {
}, errors);
});
}
ts.supportedLocaleDirectories.forEach(locale => verifyValidateLocale(locale, /*expctedToReadFile*/ true));
["en", "en-us"].forEach(locale => verifyValidateLocale(locale, /*expctedToReadFile*/ false));
ts.supportedLocaleDirectories.forEach(locale => verifyValidateLocale(locale, /*expectedToReadFile*/ true));
["en", "en-us"].forEach(locale => verifyValidateLocale(locale, /*expectedToReadFile*/ false));
});

describe("unittests:: Public APIs :: forEachChild of @param comments in JSDoc", () => {
const content = `
/**
* @param The {@link TypeReferencesInAedoc}.
*/
var x
`;
const sourceFile = ts.createSourceFile("/file.ts", content, ts.ScriptTarget.ESNext, /*setParentNodes*/ true);
const paramTag = sourceFile.getChildren()[0].getChildren()[0].getChildren()[0].getChildren()[0];
const kids = paramTag.getChildren();
const seen: Set<ts.Node> = new Set();
ts.forEachChild(paramTag, n => {
assert.strictEqual(/*actual*/ false, seen.has(n), "Found a duplicate-added child");
seen.add(n);
});
assert.equal(5, kids.length);
});

0 comments on commit 8e1bf08

Please sign in to comment.