Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1842,9 +1842,9 @@ namespace ts {
(node as ModuleDeclaration).body;
}

export function getJSDocCommentsAndTags(node: Node): ReadonlyArray<JSDoc | JSDocTag> {
export function getJSDocCommentsAndTags(hostNode: Node): ReadonlyArray<JSDoc | JSDocTag> {
let result: (JSDoc | JSDocTag)[] | undefined;
getJSDocCommentsAndTagsWorker(node);
getJSDocCommentsAndTagsWorker(hostNode);
return result || emptyArray;

function getJSDocCommentsAndTagsWorker(node: Node): void {
Expand All @@ -1860,7 +1860,7 @@ namespace ts {
// */
// var x = function(name) { return name.length; }
if (parent.parent &&
(getSingleVariableOfVariableStatement(parent.parent) === node || getSourceOfAssignment(parent.parent))) {
(getSingleVariableOfVariableStatement(parent.parent) === node)) {
getJSDocCommentsAndTagsWorker(parent.parent);
}
if (parent.parent && parent.parent.parent &&
Expand All @@ -1869,8 +1869,8 @@ namespace ts {
getSourceOfDefaultedAssignment(parent.parent.parent))) {
getJSDocCommentsAndTagsWorker(parent.parent.parent);
}
if (isBinaryExpression(node) && getSpecialPropertyAssignmentKind(node) !== SpecialPropertyAssignmentKind.None ||
isBinaryExpression(parent) && getSpecialPropertyAssignmentKind(parent) !== SpecialPropertyAssignmentKind.None ||
if (isBinaryExpression(node) && node.operatorToken.kind === SyntaxKind.EqualsToken ||
isBinaryExpression(parent) && parent.operatorToken.kind === SyntaxKind.EqualsToken ||
node.kind === SyntaxKind.PropertyAccessExpression && node.parent && node.parent.kind === SyntaxKind.ExpressionStatement) {
getJSDocCommentsAndTagsWorker(parent);
}
Expand All @@ -1880,7 +1880,7 @@ namespace ts {
result = addRange(result, getJSDocParameterTags(node as ParameterDeclaration));
}

if (isVariableLike(node) && hasInitializer(node) && hasJSDocNodes(node.initializer)) {
if (isVariableLike(node) && hasInitializer(node) && node.initializer !== hostNode && hasJSDocNodes(node.initializer)) {
result = addRange(result, node.initializer.jsDoc);
}

Expand Down Expand Up @@ -4771,7 +4771,9 @@ namespace ts {
let tags = (node as JSDocContainer).jsDocCache;
// If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing.
if (tags === undefined) {
(node as JSDocContainer).jsDocCache = tags = flatMap(getJSDocCommentsAndTags(node), j => isJSDoc(j) ? j.tags : j);
const comments = getJSDocCommentsAndTags(node);
Debug.assert(comments.length < 2 || comments[0] !== comments[1]);
(node as JSDocContainer).jsDocCache = tags = flatMap(comments, j => isJSDoc(j) ? j.tags : j);
}
return tags;
}
Expand Down
5 changes: 1 addition & 4 deletions tests/cases/fourslash/importJsNodeModule3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@ edit.backspace(2);
edit.insert('z(');
verify.signatureHelp({
text: "z(a: number | boolean, b: string[]): string",
// TODO: GH#24129
parameterDocComment: "The first param\nThe first param",
parameterDocComment: "The first param",
tags: [
{ name: "param", text: "a The first param" },
{ name: "param", text: "b The second param" },
{ name: "param", text: "a The first param" },
{ name: "param", text: "b The second param" },
],
});