@@ -11105,26 +11105,30 @@ namespace ts {
11105
11105
* but this function's special-case code fakes alias resolution as well.
11106
11106
*/
11107
11107
function getTypeFromJSDocValueReference(node: NodeWithTypeArguments, symbol: Symbol): Type | undefined {
11108
- const valueType = getTypeOfSymbol(symbol);
11109
- let typeType = valueType;
11110
- if (symbol.valueDeclaration) {
11111
- const decl = getRootDeclaration(symbol.valueDeclaration);
11112
- let isRequireAlias = false;
11113
- if (isVariableDeclaration(decl) && decl.initializer) {
11114
- let expr = decl.initializer;
11115
- // skip past entity names, eg `require("x").a.b.c`
11116
- while (isPropertyAccessExpression(expr)) {
11117
- expr = expr.expression;
11108
+ const links = getSymbolLinks(symbol);
11109
+ if (!links.resolvedJSDocType) {
11110
+ const valueType = getTypeOfSymbol(symbol);
11111
+ let typeType = valueType;
11112
+ if (symbol.valueDeclaration) {
11113
+ const decl = getRootDeclaration(symbol.valueDeclaration);
11114
+ let isRequireAlias = false;
11115
+ if (isVariableDeclaration(decl) && decl.initializer) {
11116
+ let expr = decl.initializer;
11117
+ // skip past entity names, eg `require("x").a.b.c`
11118
+ while (isPropertyAccessExpression(expr)) {
11119
+ expr = expr.expression;
11120
+ }
11121
+ isRequireAlias = isCallExpression(expr) && isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !!valueType.symbol;
11122
+ }
11123
+ const isImportTypeWithQualifier = node.kind === SyntaxKind.ImportType && (node as ImportTypeNode).qualifier;
11124
+ // valueType might not have a symbol, eg, {import('./b').STRING_LITERAL}
11125
+ if (valueType.symbol && (isRequireAlias || isImportTypeWithQualifier)) {
11126
+ typeType = getTypeReferenceType(node, valueType.symbol);
11118
11127
}
11119
- isRequireAlias = isCallExpression(expr) && isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !!valueType.symbol;
11120
- }
11121
- const isImportTypeWithQualifier = node.kind === SyntaxKind.ImportType && (node as ImportTypeNode).qualifier;
11122
- // valueType might not have a symbol, eg, {import('./b').STRING_LITERAL}
11123
- if (valueType.symbol && (isRequireAlias || isImportTypeWithQualifier)) {
11124
- typeType = getTypeReferenceType(node, valueType.symbol);
11125
11128
}
11129
+ links.resolvedJSDocType = typeType;
11126
11130
}
11127
- return getSymbolLinks(symbol) .resolvedJSDocType = typeType ;
11131
+ return links .resolvedJSDocType;
11128
11132
}
11129
11133
11130
11134
function getSubstitutionType(typeVariable: TypeVariable, substitute: Type) {
0 commit comments