fix(58151): JSDoc tags get lost when inheriting from a grandparent class (#58183)

This commit is contained in:
Oleksandr T 2024-04-16 01:47:40 +03:00 committed by GitHub
parent 9d8f812a83
commit 4b01686602
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 207 additions and 1 deletions

View File

@ -740,6 +740,7 @@ class SymbolObject implements Symbol {
getJsDocTags(checker?: TypeChecker): JSDocTagInfo[] {
if (this.tags === undefined) {
this.tags = emptyArray; // Set temporarily to avoid an infinite loop finding inherited tags
this.tags = getJsDocTagsOfDeclarations(this.declarations, checker);
}
@ -988,7 +989,7 @@ function getJsDocTagsOfDeclarations(declarations: Declaration[] | undefined, che
if (declaration.kind === SyntaxKind.GetAccessor || declaration.kind === SyntaxKind.SetAccessor) {
return symbol.getContextualJsDocTags(declaration, checker);
}
return symbol.declarations?.length === 1 ? symbol.getJsDocTags() : undefined;
return symbol.declarations?.length === 1 ? symbol.getJsDocTags(checker) : undefined;
}
});
if (inheritedTags) {

View File

@ -0,0 +1,185 @@
// === QuickInfo ===
=== /tests/cases/fourslash/quickInfoJsDocTags16.ts ===
// class A {
// /**
// * Description text here.
// *
// * @virtual
// */
// foo() { }
// }
//
// class B extends A {
// override foo() { }
// ^^^
// | ----------------------------------------------------------------------
// | (method) B.foo(): void
// | Description text here.
// | @virtual
// | ----------------------------------------------------------------------
// }
//
// class C extends B {
// override foo() { }
// ^^^
// | ----------------------------------------------------------------------
// | (method) C.foo(): void
// | Description text here.
// | @virtual
// | ----------------------------------------------------------------------
// }
[
{
"marker": {
"fileName": "/tests/cases/fourslash/quickInfoJsDocTags16.ts",
"position": 129,
"name": "1"
},
"item": {
"kind": "method",
"kindModifiers": "",
"textSpan": {
"start": 129,
"length": 3
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "B",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "foo",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"documentation": [
{
"text": "Description text here.",
"kind": "text"
}
],
"tags": [
{
"name": "virtual"
}
]
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/quickInfoJsDocTags16.ts",
"position": 175,
"name": "2"
},
"item": {
"kind": "method",
"kindModifiers": "",
"textSpan": {
"start": 175,
"length": 3
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "method",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "C",
"kind": "className"
},
{
"text": ".",
"kind": "punctuation"
},
{
"text": "foo",
"kind": "methodName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"documentation": [
{
"text": "Description text here.",
"kind": "text"
}
],
"tags": [
{
"name": "virtual"
}
]
}
}
]

View File

@ -0,0 +1,20 @@
///<reference path="fourslash.ts" />
////class A {
//// /**
//// * Description text here.
//// *
//// * @virtual
//// */
//// foo() { }
////}
////
////class B extends A {
//// override /*1*/foo() { }
////}
////
////class C extends B {
//// override /*2*/foo() { }
////}
verify.baselineQuickInfo();