From e74dd02e08a35899a0beed0c3229484d5cd7e027 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 16 Mar 2024 07:41:37 -0700 Subject: [PATCH] Skip CFA on obj[key] where key isn't a known property name --- src/compiler/checker.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c8eefa77783..f0546ef99be 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -33183,6 +33183,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return getFlowTypeOfProperty(node, prop); } propType = getNarrowableTypeForReference(propType, node, checkMode); + if (isElementAccessExpression(node) && !tryGetElementAccessExpressionName(node)) { + return propType; + } // If strict null checks and strict property initialization checks are enabled, if we have // a this.xxx property access, if the property is an instance property without an initializer, // and if we are in a constructor of the same class as the property declaration, assume that