Skip to content

Commit 0a1090d

Browse files
committed
Correctly resolve tags for function overloads. Fixes microsoft#30181
1 parent d62c8a4 commit 0a1090d

File tree

2 files changed

+64
-2
lines changed

2 files changed

+64
-2
lines changed

src/services/symbolDisplay.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ namespace ts.SymbolDisplay {
135135
let printer: Printer;
136136
let documentationFromAlias: SymbolDisplayPart[] | undefined;
137137
let tagsFromAlias: JSDocTagInfo[] | undefined;
138+
let signature: Signature | undefined;
138139

139140
if (location.kind === SyntaxKind.ThisKeyword && !isThisExpression) {
140141
return { displayParts: [keywordPart(SyntaxKind.ThisKeyword)], documentation: [], symbolKind: ScriptElementKind.primitiveType, tags: undefined };
@@ -147,7 +148,6 @@ namespace ts.SymbolDisplay {
147148
symbolKind = ScriptElementKind.memberVariableElement;
148149
}
149150

150-
let signature: Signature | undefined;
151151
type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol.exportSymbol || symbol, location);
152152

153153
if (location.parent && location.parent.kind === SyntaxKind.PropertyAccessExpression) {
@@ -501,7 +501,7 @@ namespace ts.SymbolDisplay {
501501

502502
if (!documentation) {
503503
documentation = symbol.getDocumentationComment(typeChecker);
504-
tags = symbol.getJsDocTags();
504+
tags = signature ? signature.getJsDocTags() : symbol.getJsDocTags();
505505
if (documentation.length === 0 && symbolFlags & SymbolFlags.Property) {
506506
// For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo`
507507
// there documentation comments might be attached to the right hand side symbol of their declarations.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
// @Filename: quickInfoJsDocTagsFunctionOverload.ts
4+
////declare function /*1*/foo(): void;
5+
////
6+
/////**
7+
//// * @tag Tag text
8+
//// */
9+
////declare function /*2*/foo(x: number): void
10+
11+
goTo.marker("1");
12+
verify.verifyQuickInfoDisplayParts(
13+
"function",
14+
"declare",
15+
{ start: 17, length: 3 },
16+
[
17+
{text:"function",kind:"keyword"},
18+
{text:" ",kind:"space"},
19+
{text:"foo",kind:"functionName"},
20+
{text:"(",kind:"punctuation"},
21+
{text:")",kind:"punctuation"},
22+
{text:":",kind:"punctuation"},
23+
{text:" ",kind:"space"},
24+
{text:"void",kind:"keyword"},
25+
{text:" ",kind:"space"},
26+
{text:"(",kind:"punctuation"},
27+
{text:"+",kind:"operator"},
28+
{text:"1",kind:"numericLiteral"},
29+
{text:" ",kind:"space"},
30+
{text:"overload",kind:"text"},
31+
{text:")",kind:"punctuation"}
32+
],
33+
[]);
34+
35+
goTo.marker("2");
36+
verify.verifyQuickInfoDisplayParts(
37+
"function",
38+
"declare",
39+
{ start: 73, length: 3 },
40+
[
41+
{text:"function",kind:"keyword"},
42+
{text:" ",kind:"space"},
43+
{text:"foo",kind:"functionName"},
44+
{text:"(",kind:"punctuation"},
45+
{text:"x",kind:"parameterName"},
46+
{text:":",kind:"punctuation"},
47+
{text:" ",kind:"space"},
48+
{text:"number",kind:"keyword"},
49+
{text:")",kind:"punctuation"},
50+
{text:":",kind:"punctuation"},
51+
{text:" ",kind:"space"},
52+
{text:"void",kind:"keyword"},
53+
{text:" ",kind:"space"},
54+
{text:"(",kind:"punctuation"},
55+
{text:"+",kind:"operator"},
56+
{text:"1",kind:"numericLiteral"},
57+
{text:" ",kind:"space"},
58+
{text:"overload",kind:"text"},
59+
{text:")",kind:"punctuation"}
60+
],
61+
[],
62+
[{ name: "tag", text: "Tag text" }]);

0 commit comments

Comments
 (0)