From e80fe9d63be87ef6d826a1bed640702d7bfc605c Mon Sep 17 00:00:00 2001 From: Oleksandr T Date: Sun, 8 Nov 2020 19:10:40 +0200 Subject: [PATCH] feat(41216): show JSDoc for aliases --- 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 65543399c30d2..f4ebd7c9bbbc4 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -405,6 +405,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 0000000000000..07bb13ae3517a --- /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 0000000000000..e5b74a81d5372 --- /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();