Cache started nonexistent property error checks to prevent reentrancy in the check (#60683)

This commit is contained in:
Wesley Wigham
2024-12-04 15:13:20 -08:00
committed by GitHub
parent 4105134626
commit 517da72a57
7 changed files with 111 additions and 0 deletions
+7
View File
@@ -34466,6 +34466,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
}
function reportNonexistentProperty(propNode: Identifier | PrivateIdentifier, containingType: Type, isUncheckedJS: boolean) {
const links = getNodeLinks(propNode);
const cache = (links.nonExistentPropCheckCache ||= new Set());
const key = `${getTypeId(containingType)}|${isUncheckedJS}`;
if (cache.has(key)) {
return;
}
cache.add(key);
let errorInfo: DiagnosticMessageChain | undefined;
let relatedInfo: Diagnostic | undefined;
if (!isPrivateIdentifier(propNode) && containingType.flags & TypeFlags.Union && !(containingType.flags & TypeFlags.Primitive)) {
+1
View File
@@ -6254,6 +6254,7 @@ export interface NodeLinks {
potentialUnusedRenamedBindingElementsInTypes?: BindingElement[];
externalHelpersModule?: Symbol; // Resolved symbol for the external helpers module
instantiationExpressionTypes?: Map<number, Type>; // Cache of instantiation expression types for the node
nonExistentPropCheckCache?: Set<string>;
}
/** @internal */