From 924f536ba67a80b7cb40981f42919a719e02b440 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 5 Apr 2017 11:02:42 -0700 Subject: [PATCH] Stop looking at control flow containers for `this` References to `this` should not continue looking outside their immediate container to narrow. Introduced by #11458, which allows narrowing of captured variables inside methods of class expressions. --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7bdde91f286..fe9389bce0a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11009,7 +11009,7 @@ namespace ts { else if (flow.flags & FlowFlags.Start) { // Check if we should continue with the control flow of the containing function. const container = (flow).container; - if (container && container !== flowContainer && reference.kind !== SyntaxKind.PropertyAccessExpression) { + if (container && container !== flowContainer && reference.kind !== SyntaxKind.PropertyAccessExpression && reference.kind !== SyntaxKind.ThisKeyword) { flow = container.flowNode; continue; }