Skip to content

Commit 4b01686

Browse files
authored
fix(58151): JSDoc tags get lost when inheriting from a grandparent class (#58183)
1 parent 9d8f812 commit 4b01686

File tree

3 files changed

+207
-1
lines changed

3 files changed

+207
-1
lines changed

src/services/services.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,7 @@ class SymbolObject implements Symbol {
740740

741741
getJsDocTags(checker?: TypeChecker): JSDocTagInfo[] {
742742
if (this.tags === undefined) {
743+
this.tags = emptyArray; // Set temporarily to avoid an infinite loop finding inherited tags
743744
this.tags = getJsDocTagsOfDeclarations(this.declarations, checker);
744745
}
745746

@@ -988,7 +989,7 @@ function getJsDocTagsOfDeclarations(declarations: Declaration[] | undefined, che
988989
if (declaration.kind === SyntaxKind.GetAccessor || declaration.kind === SyntaxKind.SetAccessor) {
989990
return symbol.getContextualJsDocTags(declaration, checker);
990991
}
991-
return symbol.declarations?.length === 1 ? symbol.getJsDocTags() : undefined;
992+
return symbol.declarations?.length === 1 ? symbol.getJsDocTags(checker) : undefined;
992993
}
993994
});
994995
if (inheritedTags) {
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
// === QuickInfo ===
2+
=== /tests/cases/fourslash/quickInfoJsDocTags16.ts ===
3+
// class A {
4+
// /**
5+
// * Description text here.
6+
// *
7+
// * @virtual
8+
// */
9+
// foo() { }
10+
// }
11+
//
12+
// class B extends A {
13+
// override foo() { }
14+
// ^^^
15+
// | ----------------------------------------------------------------------
16+
// | (method) B.foo(): void
17+
// | Description text here.
18+
// | @virtual
19+
// | ----------------------------------------------------------------------
20+
// }
21+
//
22+
// class C extends B {
23+
// override foo() { }
24+
// ^^^
25+
// | ----------------------------------------------------------------------
26+
// | (method) C.foo(): void
27+
// | Description text here.
28+
// | @virtual
29+
// | ----------------------------------------------------------------------
30+
// }
31+
32+
[
33+
{
34+
"marker": {
35+
"fileName": "/tests/cases/fourslash/quickInfoJsDocTags16.ts",
36+
"position": 129,
37+
"name": "1"
38+
},
39+
"item": {
40+
"kind": "method",
41+
"kindModifiers": "",
42+
"textSpan": {
43+
"start": 129,
44+
"length": 3
45+
},
46+
"displayParts": [
47+
{
48+
"text": "(",
49+
"kind": "punctuation"
50+
},
51+
{
52+
"text": "method",
53+
"kind": "text"
54+
},
55+
{
56+
"text": ")",
57+
"kind": "punctuation"
58+
},
59+
{
60+
"text": " ",
61+
"kind": "space"
62+
},
63+
{
64+
"text": "B",
65+
"kind": "className"
66+
},
67+
{
68+
"text": ".",
69+
"kind": "punctuation"
70+
},
71+
{
72+
"text": "foo",
73+
"kind": "methodName"
74+
},
75+
{
76+
"text": "(",
77+
"kind": "punctuation"
78+
},
79+
{
80+
"text": ")",
81+
"kind": "punctuation"
82+
},
83+
{
84+
"text": ":",
85+
"kind": "punctuation"
86+
},
87+
{
88+
"text": " ",
89+
"kind": "space"
90+
},
91+
{
92+
"text": "void",
93+
"kind": "keyword"
94+
}
95+
],
96+
"documentation": [
97+
{
98+
"text": "Description text here.",
99+
"kind": "text"
100+
}
101+
],
102+
"tags": [
103+
{
104+
"name": "virtual"
105+
}
106+
]
107+
}
108+
},
109+
{
110+
"marker": {
111+
"fileName": "/tests/cases/fourslash/quickInfoJsDocTags16.ts",
112+
"position": 175,
113+
"name": "2"
114+
},
115+
"item": {
116+
"kind": "method",
117+
"kindModifiers": "",
118+
"textSpan": {
119+
"start": 175,
120+
"length": 3
121+
},
122+
"displayParts": [
123+
{
124+
"text": "(",
125+
"kind": "punctuation"
126+
},
127+
{
128+
"text": "method",
129+
"kind": "text"
130+
},
131+
{
132+
"text": ")",
133+
"kind": "punctuation"
134+
},
135+
{
136+
"text": " ",
137+
"kind": "space"
138+
},
139+
{
140+
"text": "C",
141+
"kind": "className"
142+
},
143+
{
144+
"text": ".",
145+
"kind": "punctuation"
146+
},
147+
{
148+
"text": "foo",
149+
"kind": "methodName"
150+
},
151+
{
152+
"text": "(",
153+
"kind": "punctuation"
154+
},
155+
{
156+
"text": ")",
157+
"kind": "punctuation"
158+
},
159+
{
160+
"text": ":",
161+
"kind": "punctuation"
162+
},
163+
{
164+
"text": " ",
165+
"kind": "space"
166+
},
167+
{
168+
"text": "void",
169+
"kind": "keyword"
170+
}
171+
],
172+
"documentation": [
173+
{
174+
"text": "Description text here.",
175+
"kind": "text"
176+
}
177+
],
178+
"tags": [
179+
{
180+
"name": "virtual"
181+
}
182+
]
183+
}
184+
}
185+
]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
///<reference path="fourslash.ts" />
2+
3+
////class A {
4+
//// /**
5+
//// * Description text here.
6+
//// *
7+
//// * @virtual
8+
//// */
9+
//// foo() { }
10+
////}
11+
////
12+
////class B extends A {
13+
//// override /*1*/foo() { }
14+
////}
15+
////
16+
////class C extends B {
17+
//// override /*2*/foo() { }
18+
////}
19+
20+
verify.baselineQuickInfo();

0 commit comments

Comments
 (0)