From 5adb55eb1815db7b2b2dd98374848886a3c7d16f Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Wed, 25 Nov 2020 00:40:51 +0200 Subject: [PATCH] feat(41216): show JSDoc for aliases (#41452) --- src/services/symbolDisplay.ts | 4 + .../reference/jsDocAliasQuickInfo.baseline | 162 ++++++++++++++++++ tests/cases/fourslash/jsDocAliasQuickInfo.ts | 13 ++ 3 files changed, 179 insertions(+) create mode 100644 tests/baselines/reference/jsDocAliasQuickInfo.baseline create mode 100644 tests/cases/fourslash/jsDocAliasQuickInfo.ts diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 6813ad3f9bc..2a2a1f846d5 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -422,6 +422,10 @@ namespace ts.SymbolDisplay { documentationFromAlias = resolvedInfo.documentation; tagsFromAlias = resolvedInfo.tags; } + else { + documentationFromAlias = resolvedSymbol.getContextualDocumentationComment(resolvedNode, typeChecker); + tagsFromAlias = resolvedSymbol.getJsDocTags(); + } } } diff --git a/tests/baselines/reference/jsDocAliasQuickInfo.baseline b/tests/baselines/reference/jsDocAliasQuickInfo.baseline new file mode 100644 index 00000000000..07bb13ae351 --- /dev/null +++ b/tests/baselines/reference/jsDocAliasQuickInfo.baseline @@ -0,0 +1,162 @@ +[ + { + "marker": { + "fileName": "/jsDocAliasQuickInfo.ts", + "position": 44 + }, + "quickInfo": { + "kind": "property", + "kindModifiers": "export", + "textSpan": { + "start": 44, + "length": 7 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "default", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "10", + "kind": "stringLiteral" + } + ], + "documentation": [ + { + "text": "Comment", + "kind": "text" + } + ], + "tags": [ + { + "name": "type", + "text": "{number}" + } + ] + } + }, + { + "marker": { + "fileName": "/test.ts", + "position": 9 + }, + "quickInfo": { + "kind": "property", + "kindModifiers": "export", + "textSpan": { + "start": 9, + "length": 7 + }, + "displayParts": [ + { + "text": "(", + "kind": "punctuation" + }, + { + "text": "property", + "kind": "text" + }, + { + "text": ")", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "default", + "kind": "propertyName" + }, + { + "text": ":", + "kind": "punctuation" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "10", + "kind": "stringLiteral" + } + ], + "documentation": [ + { + "text": "Comment", + "kind": "text" + } + ], + "tags": [ + { + "name": "type", + "text": "{number}" + } + ] + } + }, + { + "marker": { + "fileName": "/test.ts", + "position": 20 + }, + "quickInfo": { + "kind": "alias", + "kindModifiers": "", + "textSpan": { + "start": 20, + "length": 4 + }, + "displayParts": [ + { + "text": "export", + "kind": "keyword" + }, + { + "text": " ", + "kind": "space" + }, + { + "text": "test", + "kind": "aliasName" + } + ], + "documentation": [ + { + "text": "Comment", + "kind": "text" + } + ], + "tags": [ + { + "name": "type", + "text": "{number}" + } + ] + } + } +] \ No newline at end of file diff --git a/tests/cases/fourslash/jsDocAliasQuickInfo.ts b/tests/cases/fourslash/jsDocAliasQuickInfo.ts new file mode 100644 index 00000000000..e5b74a81d53 --- /dev/null +++ b/tests/cases/fourslash/jsDocAliasQuickInfo.ts @@ -0,0 +1,13 @@ +/// + +// @Filename: /jsDocAliasQuickInfo.ts +/////** +//// * Comment +//// * @type {number} +//// */ +////export /*1*/default 10; + +// @Filename: /test.ts +////export { /*2*/default as /*3*/test } from "./jsDocAliasQuickInfo"; + +verify.baselineQuickInfo();