Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aec732a

Browse filesBrowse files
authored
Actually use the caches resolvedJSDocType (microsoft#36516)
1 parent 36169b4 commit aec732a
Copy full SHA for aec732a

File tree

Expand file treeCollapse file tree

1 file changed

+21
-17
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+21
-17
lines changed

‎src/compiler/checker.ts

Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+21-17Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11105,26 +11105,30 @@ namespace ts {
1110511105
* but this function's special-case code fakes alias resolution as well.
1110611106
*/
1110711107
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);
1111811127
}
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);
1112511128
}
11129+
links.resolvedJSDocType = typeType;
1112611130
}
11127-
return getSymbolLinks(symbol).resolvedJSDocType = typeType;
11131+
return links.resolvedJSDocType;
1112811132
}
1112911133

1113011134
function getSubstitutionType(typeVariable: TypeVariable, substitute: Type) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.