Skip to content

Commit f25f2bb

Browse files
authored
fix(55939): JS Doc comment not shown in signature help when overload tag exists (#56139)
1 parent a25321a commit f25f2bb

File tree

3 files changed

+404
-0
lines changed

3 files changed

+404
-0
lines changed

src/services/jsDoc.ts

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
isFunctionTypeNode,
4444
isIdentifier,
4545
isJSDoc,
46+
isJSDocOverloadTag,
4647
isJSDocParameterTag,
4748
isJSDocPropertyLikeTag,
4849
isJSDocTypeLiteral,
@@ -230,6 +231,11 @@ function getCommentHavingNodes(declaration: Declaration): readonly (JSDoc | JSDo
230231
case SyntaxKind.JSDocCallbackTag:
231232
case SyntaxKind.JSDocTypedefTag:
232233
return [declaration as JSDocTypedefTag, (declaration as JSDocTypedefTag).parent];
234+
case SyntaxKind.JSDocSignature:
235+
if (isJSDocOverloadTag(declaration.parent)) {
236+
return [declaration.parent.parent];
237+
}
238+
// falls through
233239
default:
234240
return getJSDocCommentsAndTags(declaration);
235241
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,369 @@
1+
// === SignatureHelp ===
2+
=== /tests/cases/fourslash/./a.js ===
3+
// /**
4+
// * First overload
5+
// * @overload
6+
// * @param {number} a
7+
// * @returns {void}
8+
// */
9+
//
10+
// /**
11+
// * Second overload
12+
// * @overload
13+
// * @param {string} a
14+
// * @returns {void}
15+
// */
16+
//
17+
// /**
18+
// * @param {string | number} a
19+
// * @returns {void}
20+
// */
21+
// function f(a) {}
22+
//
23+
// f(1);
24+
// ^
25+
// | ----------------------------------------------------------------------
26+
// | f(**a: number**): void
27+
// | First overload
28+
// | ----------------------------------------------------------------------
29+
// f("");
30+
// ^
31+
// | ----------------------------------------------------------------------
32+
// | f(**a: string**): void
33+
// | Second overload
34+
// | ----------------------------------------------------------------------
35+
36+
[
37+
{
38+
"marker": {
39+
"fileName": "/tests/cases/fourslash/./a.js",
40+
"position": 238,
41+
"name": "a"
42+
},
43+
"item": {
44+
"items": [
45+
{
46+
"isVariadic": false,
47+
"prefixDisplayParts": [
48+
{
49+
"text": "f",
50+
"kind": "functionName"
51+
},
52+
{
53+
"text": "(",
54+
"kind": "punctuation"
55+
}
56+
],
57+
"suffixDisplayParts": [
58+
{
59+
"text": ")",
60+
"kind": "punctuation"
61+
},
62+
{
63+
"text": ":",
64+
"kind": "punctuation"
65+
},
66+
{
67+
"text": " ",
68+
"kind": "space"
69+
},
70+
{
71+
"text": "void",
72+
"kind": "keyword"
73+
}
74+
],
75+
"separatorDisplayParts": [
76+
{
77+
"text": ",",
78+
"kind": "punctuation"
79+
},
80+
{
81+
"text": " ",
82+
"kind": "space"
83+
}
84+
],
85+
"parameters": [
86+
{
87+
"name": "a",
88+
"documentation": [],
89+
"displayParts": [
90+
{
91+
"text": "a",
92+
"kind": "parameterName"
93+
},
94+
{
95+
"text": ":",
96+
"kind": "punctuation"
97+
},
98+
{
99+
"text": " ",
100+
"kind": "space"
101+
},
102+
{
103+
"text": "number",
104+
"kind": "keyword"
105+
}
106+
],
107+
"isOptional": false,
108+
"isRest": false
109+
}
110+
],
111+
"documentation": [
112+
{
113+
"text": "First overload",
114+
"kind": "text"
115+
}
116+
],
117+
"tags": []
118+
},
119+
{
120+
"isVariadic": false,
121+
"prefixDisplayParts": [
122+
{
123+
"text": "f",
124+
"kind": "functionName"
125+
},
126+
{
127+
"text": "(",
128+
"kind": "punctuation"
129+
}
130+
],
131+
"suffixDisplayParts": [
132+
{
133+
"text": ")",
134+
"kind": "punctuation"
135+
},
136+
{
137+
"text": ":",
138+
"kind": "punctuation"
139+
},
140+
{
141+
"text": " ",
142+
"kind": "space"
143+
},
144+
{
145+
"text": "void",
146+
"kind": "keyword"
147+
}
148+
],
149+
"separatorDisplayParts": [
150+
{
151+
"text": ",",
152+
"kind": "punctuation"
153+
},
154+
{
155+
"text": " ",
156+
"kind": "space"
157+
}
158+
],
159+
"parameters": [
160+
{
161+
"name": "a",
162+
"documentation": [],
163+
"displayParts": [
164+
{
165+
"text": "a",
166+
"kind": "parameterName"
167+
},
168+
{
169+
"text": ":",
170+
"kind": "punctuation"
171+
},
172+
{
173+
"text": " ",
174+
"kind": "space"
175+
},
176+
{
177+
"text": "string",
178+
"kind": "keyword"
179+
}
180+
],
181+
"isOptional": false,
182+
"isRest": false
183+
}
184+
],
185+
"documentation": [
186+
{
187+
"text": "Second overload",
188+
"kind": "text"
189+
}
190+
],
191+
"tags": []
192+
}
193+
],
194+
"applicableSpan": {
195+
"start": 238,
196+
"length": 1
197+
},
198+
"selectedItemIndex": 0,
199+
"argumentIndex": 0,
200+
"argumentCount": 1
201+
}
202+
},
203+
{
204+
"marker": {
205+
"fileName": "/tests/cases/fourslash/./a.js",
206+
"position": 244,
207+
"name": "b"
208+
},
209+
"item": {
210+
"items": [
211+
{
212+
"isVariadic": false,
213+
"prefixDisplayParts": [
214+
{
215+
"text": "f",
216+
"kind": "functionName"
217+
},
218+
{
219+
"text": "(",
220+
"kind": "punctuation"
221+
}
222+
],
223+
"suffixDisplayParts": [
224+
{
225+
"text": ")",
226+
"kind": "punctuation"
227+
},
228+
{
229+
"text": ":",
230+
"kind": "punctuation"
231+
},
232+
{
233+
"text": " ",
234+
"kind": "space"
235+
},
236+
{
237+
"text": "void",
238+
"kind": "keyword"
239+
}
240+
],
241+
"separatorDisplayParts": [
242+
{
243+
"text": ",",
244+
"kind": "punctuation"
245+
},
246+
{
247+
"text": " ",
248+
"kind": "space"
249+
}
250+
],
251+
"parameters": [
252+
{
253+
"name": "a",
254+
"documentation": [],
255+
"displayParts": [
256+
{
257+
"text": "a",
258+
"kind": "parameterName"
259+
},
260+
{
261+
"text": ":",
262+
"kind": "punctuation"
263+
},
264+
{
265+
"text": " ",
266+
"kind": "space"
267+
},
268+
{
269+
"text": "number",
270+
"kind": "keyword"
271+
}
272+
],
273+
"isOptional": false,
274+
"isRest": false
275+
}
276+
],
277+
"documentation": [
278+
{
279+
"text": "First overload",
280+
"kind": "text"
281+
}
282+
],
283+
"tags": []
284+
},
285+
{
286+
"isVariadic": false,
287+
"prefixDisplayParts": [
288+
{
289+
"text": "f",
290+
"kind": "functionName"
291+
},
292+
{
293+
"text": "(",
294+
"kind": "punctuation"
295+
}
296+
],
297+
"suffixDisplayParts": [
298+
{
299+
"text": ")",
300+
"kind": "punctuation"
301+
},
302+
{
303+
"text": ":",
304+
"kind": "punctuation"
305+
},
306+
{
307+
"text": " ",
308+
"kind": "space"
309+
},
310+
{
311+
"text": "void",
312+
"kind": "keyword"
313+
}
314+
],
315+
"separatorDisplayParts": [
316+
{
317+
"text": ",",
318+
"kind": "punctuation"
319+
},
320+
{
321+
"text": " ",
322+
"kind": "space"
323+
}
324+
],
325+
"parameters": [
326+
{
327+
"name": "a",
328+
"documentation": [],
329+
"displayParts": [
330+
{
331+
"text": "a",
332+
"kind": "parameterName"
333+
},
334+
{
335+
"text": ":",
336+
"kind": "punctuation"
337+
},
338+
{
339+
"text": " ",
340+
"kind": "space"
341+
},
342+
{
343+
"text": "string",
344+
"kind": "keyword"
345+
}
346+
],
347+
"isOptional": false,
348+
"isRest": false
349+
}
350+
],
351+
"documentation": [
352+
{
353+
"text": "Second overload",
354+
"kind": "text"
355+
}
356+
],
357+
"tags": []
358+
}
359+
],
360+
"applicableSpan": {
361+
"start": 244,
362+
"length": 2
363+
},
364+
"selectedItemIndex": 1,
365+
"argumentIndex": 0,
366+
"argumentCount": 1
367+
}
368+
}
369+
]

0 commit comments

Comments
 (0)