Skip to content

fix(55939): JS Doc comment not shown in signature help when overload tag exists #56139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 27, 2023
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
6 changes: 6 additions & 0 deletions src/services/jsDoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
isFunctionTypeNode,
isIdentifier,
isJSDoc,
isJSDocOverloadTag,
isJSDocParameterTag,
isJSDocPropertyLikeTag,
isJSDocTypeLiteral,
Expand Down Expand Up @@ -230,6 +231,11 @@ function getCommentHavingNodes(declaration: Declaration): readonly (JSDoc | JSDo
case SyntaxKind.JSDocCallbackTag:
case SyntaxKind.JSDocTypedefTag:
return [declaration as JSDocTypedefTag, (declaration as JSDocTypedefTag).parent];
case SyntaxKind.JSDocSignature:
if (isJSDocOverloadTag(declaration.parent)) {
return [declaration.parent.parent];
}
// falls through
default:
return getJSDocCommentsAndTags(declaration);
}
Expand Down
369 changes: 369 additions & 0 deletions tests/baselines/reference/quickInfoJsDocTags13.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,369 @@
// === SignatureHelp ===
=== /tests/cases/fourslash/./a.js ===
// /**
// * First overload
// * @overload
// * @param {number} a
// * @returns {void}
// */
//
// /**
// * Second overload
// * @overload
// * @param {string} a
// * @returns {void}
// */
//
// /**
// * @param {string | number} a
// * @returns {void}
// */
// function f(a) {}
//
// f(1);
// ^
// | ----------------------------------------------------------------------
// | f(**a: number**): void
// | First overload
// | ----------------------------------------------------------------------
// f("");
// ^
// | ----------------------------------------------------------------------
// | f(**a: string**): void
// | Second overload
// | ----------------------------------------------------------------------

[
{
"marker": {
"fileName": "/tests/cases/fourslash/./a.js",
"position": 238,
"name": "a"
},
"item": {
"items": [
{
"isVariadic": false,
"prefixDisplayParts": [
{
"text": "f",
"kind": "functionName"
},
{
"text": "(",
"kind": "punctuation"
}
],
"suffixDisplayParts": [
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"separatorDisplayParts": [
{
"text": ",",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
}
],
"parameters": [
{
"name": "a",
"documentation": [],
"displayParts": [
{
"text": "a",
"kind": "parameterName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "number",
"kind": "keyword"
}
],
"isOptional": false,
"isRest": false
}
],
"documentation": [
{
"text": "First overload",
"kind": "text"
}
],
"tags": []
},
{
"isVariadic": false,
"prefixDisplayParts": [
{
"text": "f",
"kind": "functionName"
},
{
"text": "(",
"kind": "punctuation"
}
],
"suffixDisplayParts": [
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"separatorDisplayParts": [
{
"text": ",",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
}
],
"parameters": [
{
"name": "a",
"documentation": [],
"displayParts": [
{
"text": "a",
"kind": "parameterName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "string",
"kind": "keyword"
}
],
"isOptional": false,
"isRest": false
}
],
"documentation": [
{
"text": "Second overload",
"kind": "text"
}
],
"tags": []
}
],
"applicableSpan": {
"start": 238,
"length": 1
},
"selectedItemIndex": 0,
"argumentIndex": 0,
"argumentCount": 1
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/./a.js",
"position": 244,
"name": "b"
},
"item": {
"items": [
{
"isVariadic": false,
"prefixDisplayParts": [
{
"text": "f",
"kind": "functionName"
},
{
"text": "(",
"kind": "punctuation"
}
],
"suffixDisplayParts": [
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"separatorDisplayParts": [
{
"text": ",",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
}
],
"parameters": [
{
"name": "a",
"documentation": [],
"displayParts": [
{
"text": "a",
"kind": "parameterName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "number",
"kind": "keyword"
}
],
"isOptional": false,
"isRest": false
}
],
"documentation": [
{
"text": "First overload",
"kind": "text"
}
],
"tags": []
},
{
"isVariadic": false,
"prefixDisplayParts": [
{
"text": "f",
"kind": "functionName"
},
{
"text": "(",
"kind": "punctuation"
}
],
"suffixDisplayParts": [
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"separatorDisplayParts": [
{
"text": ",",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
}
],
"parameters": [
{
"name": "a",
"documentation": [],
"displayParts": [
{
"text": "a",
"kind": "parameterName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "string",
"kind": "keyword"
}
],
"isOptional": false,
"isRest": false
}
],
"documentation": [
{
"text": "Second overload",
"kind": "text"
}
],
"tags": []
}
],
"applicableSpan": {
"start": 244,
"length": 2
},
"selectedItemIndex": 1,
"argumentIndex": 0,
"argumentCount": 1
}
}
]
Loading