Skip to content

Commit b60901d

Browse files
Fix duplicate visit of param tag comments (#44443) (#44444)
Fixes #44422 Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
1 parent 4f7fe4a commit b60901d

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

src/compiler/parser.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,12 +493,12 @@ namespace ts {
493493
case SyntaxKind.JSDocPropertyTag:
494494
return visitNode(cbNode, (node as JSDocTag).tagName) ||
495495
((node as JSDocPropertyLikeTag).isNameFirst
496-
? visitNode(cbNode, (<JSDocPropertyLikeTag>node).name) ||
497-
visitNode(cbNode, (<JSDocPropertyLikeTag>node).typeExpression) ||
496+
? visitNode(cbNode, (node as JSDocPropertyLikeTag).name) ||
497+
visitNode(cbNode, (node as JSDocPropertyLikeTag).typeExpression) ||
498498
(typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray<JSDocText | JSDocLink> | undefined))
499-
: visitNode(cbNode, (<JSDocPropertyLikeTag>node).typeExpression) ||
500-
visitNode(cbNode, (<JSDocPropertyLikeTag>node).name)) ||
501-
(typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray<JSDocText | JSDocLink> | undefined));
499+
: visitNode(cbNode, (node as JSDocPropertyLikeTag).typeExpression) ||
500+
visitNode(cbNode, (node as JSDocPropertyLikeTag).name) ||
501+
(typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray<JSDocText | JSDocLink> | undefined)));
502502
case SyntaxKind.JSDocAuthorTag:
503503
return visitNode(cbNode, (node as JSDocTag).tagName) ||
504504
(typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray<JSDocText | JSDocLink> | undefined));

src/testRunner/unittests/publicApi.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,24 @@ describe("unittests:: Public APIs:: validateLocaleAndSetLanguage", () => {
150150
}, errors);
151151
});
152152
}
153-
ts.supportedLocaleDirectories.forEach(locale => verifyValidateLocale(locale, /*expctedToReadFile*/ true));
154-
["en", "en-us"].forEach(locale => verifyValidateLocale(locale, /*expctedToReadFile*/ false));
153+
ts.supportedLocaleDirectories.forEach(locale => verifyValidateLocale(locale, /*expectedToReadFile*/ true));
154+
["en", "en-us"].forEach(locale => verifyValidateLocale(locale, /*expectedToReadFile*/ false));
155+
});
156+
157+
describe("unittests:: Public APIs :: forEachChild of @param comments in JSDoc", () => {
158+
const content = `
159+
/**
160+
* @param The {@link TypeReferencesInAedoc}.
161+
*/
162+
var x
163+
`;
164+
const sourceFile = ts.createSourceFile("/file.ts", content, ts.ScriptTarget.ESNext, /*setParentNodes*/ true);
165+
const paramTag = sourceFile.getChildren()[0].getChildren()[0].getChildren()[0].getChildren()[0];
166+
const kids = paramTag.getChildren();
167+
const seen: Set<ts.Node> = new Set();
168+
ts.forEachChild(paramTag, n => {
169+
assert.strictEqual(/*actual*/ false, seen.has(n), "Found a duplicate-added child");
170+
seen.add(n);
171+
});
172+
assert.equal(5, kids.length);
155173
});

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy