Cache instantiation expression types early enough to prevent reentrancy during printback (#59931)

This commit is contained in:
Wesley Wigham
2024-09-23 10:46:57 -07:00
committed by GitHub
parent 88809467e8
commit e24cc01b08
8 changed files with 204 additions and 2 deletions
+8
View File
@@ -37401,9 +37401,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
if (exprType === silentNeverType || isErrorType(exprType) || !some(typeArguments)) {
return exprType;
}
const links = getNodeLinks(node);
if (!links.instantiationExpressionTypes) {
links.instantiationExpressionTypes = new Map();
}
if (links.instantiationExpressionTypes.has(exprType.id)) {
return links.instantiationExpressionTypes.get(exprType.id)!;
}
let hasSomeApplicableSignature = false;
let nonApplicableType: Type | undefined;
const result = getInstantiatedType(exprType);
links.instantiationExpressionTypes.set(exprType.id, result);
const errorType = hasSomeApplicableSignature ? nonApplicableType : exprType;
if (errorType) {
diagnostics.add(createDiagnosticForNodeArray(getSourceFileOfNode(node), typeArguments, Diagnostics.Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable, typeToString(errorType)));
+1
View File
@@ -6239,6 +6239,7 @@ export interface NodeLinks {
potentialReflectCollisions?: Node[];
potentialUnusedRenamedBindingElementsInTypes?: BindingElement[];
externalHelpersModule?: Symbol; // Resolved symbol for the external helpers module
instantiationExpressionTypes?: Map<number, Type>; // Cache of instantiation expression types for the node
}
/** @internal */