fix(53424): in code documentation is not working upon import if function expression reuse function type (#53964)

This commit is contained in:
Oleksandr T 2023-05-09 02:55:04 +03:00 committed by GitHub
parent 6947c98929
commit 320e628a6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 108 additions and 3 deletions

View File

@ -535,12 +535,12 @@ export function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker: Typ
// don't use symbolFlags since getAliasedSymbol requires the flag on the symbol itself
if (symbol.flags & SymbolFlags.Alias) {
prefixNextMeaning();
if (!hasAddedSymbolInfo) {
if (!hasAddedSymbolInfo || documentation.length === 0 && tags.length === 0) {
const resolvedSymbol = typeChecker.getAliasedSymbol(symbol);
if (resolvedSymbol !== symbol && resolvedSymbol.declarations && resolvedSymbol.declarations.length > 0) {
const resolvedNode = resolvedSymbol.declarations[0];
const declarationName = getNameOfDeclaration(resolvedNode);
if (declarationName) {
if (declarationName && !hasAddedSymbolInfo) {
const isExternalModuleDeclaration =
isModuleWithStringLiteralName(resolvedNode) &&
hasSyntacticModifier(resolvedNode, ModifierFlags.Ambient);
@ -835,7 +835,6 @@ export function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker: Typ
documentation = allSignatures[0].getDocumentationComment(typeChecker);
tags = allSignatures[0].getJsDocTags().filter(tag => tag.name !== "deprecated"); // should only include @deprecated JSDoc tag on the first overload (#49368)
}
}
function writeTypeParametersOfSymbol(symbol: Symbol, enclosingDeclaration: Node | undefined) {

View File

@ -0,0 +1,91 @@
=== /b.ts ===
// import { A } from "./a";
// A()
// ^
// | ----------------------------------------------------------------------
// | (alias) A(): void
// | import A
// | docs - const A: T
// | ----------------------------------------------------------------------
[
{
"marker": {
"fileName": "/b.ts",
"position": 26,
"name": ""
},
"item": {
"kind": "alias",
"kindModifiers": "export,declare",
"textSpan": {
"start": 25,
"length": 1
},
"displayParts": [
{
"text": "(",
"kind": "punctuation"
},
{
"text": "alias",
"kind": "text"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "A",
"kind": "aliasName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": "import",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "A",
"kind": "aliasName"
}
],
"documentation": [
{
"text": "docs - const A: T",
"kind": "text"
}
]
}
}
]

View File

@ -0,0 +1,15 @@
/// <reference path="fourslash.ts" />
// @filename: /a.d.ts
/////** docs - type T */
////export type T = () => void;
/////**
//// * docs - const A: T
//// */
////export declare const A: T;
// @filename: /b.ts
////import { A } from "./a";
////A/**/()
verify.baselineQuickInfo();