From 4b01686602a15b2b20dacf735ac5a378ac9dd0b3 Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Tue, 16 Apr 2024 01:47:40 +0300 Subject: [PATCH] fix(58151): JSDoc tags get lost when inheriting from a grandparent class (#58183) --- src/services/services.ts | 3 +- .../reference/quickInfoJsDocTags16.baseline | 185 ++++++++++++++++++ tests/cases/fourslash/quickInfoJsDocTags16.ts | 20 ++ 3 files changed, 207 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/quickInfoJsDocTags16.baseline create mode 100644 tests/cases/fourslash/quickInfoJsDocTags16.ts diff --git a/src/services/services.ts b/src/services/services.ts index 8bbe3522e39..f97d3eb0651 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -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) { diff --git a/tests/baselines/reference/quickInfoJsDocTags16.baseline b/tests/baselines/reference/quickInfoJsDocTags16.baseline new file mode 100644 index 00000000000..10e0db6a5e0 --- /dev/null +++ b/tests/baselines/reference/quickInfoJsDocTags16.baseline @@ -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" + } + ] + } + } +] \ No newline at end of file diff --git a/tests/cases/fourslash/quickInfoJsDocTags16.ts b/tests/cases/fourslash/quickInfoJsDocTags16.ts new file mode 100644 index 00000000000..6dea41731fc --- /dev/null +++ b/tests/cases/fourslash/quickInfoJsDocTags16.ts @@ -0,0 +1,20 @@ +/// + +////class A { +//// /** +//// * Description text here. +//// * +//// * @virtual +//// */ +//// foo() { } +////} +//// +////class B extends A { +//// override /*1*/foo() { } +////} +//// +////class C extends B { +//// override /*2*/foo() { } +////} + +verify.baselineQuickInfo();