mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 02:33:53 -06:00
fix(55939): JS Doc comment not shown in signature help when overload tag exists (#56139)
This commit is contained in:
parent
a25321afce
commit
f25f2bb75d
@ -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);
|
||||
}
|
||||
|
||||
369
tests/baselines/reference/quickInfoJsDocTags13.baseline
Normal file
369
tests/baselines/reference/quickInfoJsDocTags13.baseline
Normal file
@ -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
|
||||
}
|
||||
}
|
||||
]
|
||||
29
tests/cases/fourslash/quickInfoJsDocTags13.ts
Normal file
29
tests/cases/fourslash/quickInfoJsDocTags13.ts
Normal file
@ -0,0 +1,29 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @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();
|
||||
Loading…
x
Reference in New Issue
Block a user