mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Cache instantiation expression types early enough to prevent reentrancy during printback (#59931)
This commit is contained in:
@@ -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)));
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user