diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 27d57464b5a..8ca6a6c7cae 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -43,6 +43,7 @@ import { isFunctionTypeNode, isIdentifier, isJSDoc, + isJSDocOverloadTag, isJSDocParameterTag, isJSDocPropertyLikeTag, isJSDocTypeLiteral, @@ -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); } diff --git a/tests/baselines/reference/quickInfoJsDocTags13.baseline b/tests/baselines/reference/quickInfoJsDocTags13.baseline new file mode 100644 index 00000000000..4c90d27ed34 --- /dev/null +++ b/tests/baselines/reference/quickInfoJsDocTags13.baseline @@ -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 + } + } +] \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoJsDocTags13.ts b/tests/cases/fourslash/quickInfoJsDocTags13.ts new file mode 100644 index 00000000000..31b3ebe0ab7 --- /dev/null +++ b/tests/cases/fourslash/quickInfoJsDocTags13.ts @@ -0,0 +1,29 @@ +/// + +// @allowJs: true +// @checkJs: true +// @filename: ./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(/*a*/1); +////f(/*b*/""); + +verify.baselineSignatureHelp();