@@ -488,6 +488,7 @@ export const enum ContainerFlags {
488488 HasLocals = 1 << 5 ,
489489 IsInterface = 1 << 6 ,
490490 IsObjectLiteralOrClassExpressionMethodOrAccessor = 1 << 7 ,
491+ PropagatesThisKeyword = 1 << 8 ,
491492}
492493
493494/** @internal */
@@ -1055,7 +1056,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
10551056 currentExceptionTarget = saveExceptionTarget ;
10561057 activeLabelList = saveActiveLabelList ;
10571058 hasExplicitReturn = saveHasExplicitReturn ;
1058- seenThisKeyword = node . kind === SyntaxKind . ArrowFunction ? saveSeenThisKeyword || seenThisKeyword : saveSeenThisKeyword ;
1059+ seenThisKeyword = containerFlags & ContainerFlags . PropagatesThisKeyword ? saveSeenThisKeyword || seenThisKeyword : saveSeenThisKeyword ;
10591060 }
10601061 else if ( containerFlags & ContainerFlags . IsInterface ) {
10611062 const saveSeenThisKeyword = seenThisKeyword ;
@@ -3845,23 +3846,26 @@ export function getContainerFlags(node: Node): ContainerFlags {
38453846 case SyntaxKind . FunctionDeclaration :
38463847 case SyntaxKind . ClassStaticBlockDeclaration :
38473848 return ContainerFlags . IsContainer | ContainerFlags . IsControlFlowContainer | ContainerFlags . HasLocals | ContainerFlags . IsFunctionLike ;
3849+
38483850 case SyntaxKind . MethodSignature :
38493851 case SyntaxKind . CallSignature :
38503852 case SyntaxKind . JSDocSignature :
38513853 case SyntaxKind . JSDocFunctionType :
38523854 case SyntaxKind . FunctionType :
38533855 case SyntaxKind . ConstructSignature :
38543856 case SyntaxKind . ConstructorType :
3855- return ContainerFlags . IsContainer | ContainerFlags . HasLocals | ContainerFlags . IsFunctionLike ;
3857+ return ContainerFlags . IsContainer | ContainerFlags . IsControlFlowContainer | ContainerFlags . HasLocals | ContainerFlags . IsFunctionLike | ContainerFlags . PropagatesThisKeyword ;
38563858
38573859 case SyntaxKind . JSDocImportTag :
38583860 // treat as a container to prevent using an enclosing effective host, ensuring import bindings are scoped correctly
3859- return ContainerFlags . IsContainer | ContainerFlags . HasLocals ;
3861+ return ContainerFlags . IsContainer | ContainerFlags . IsControlFlowContainer | ContainerFlags . HasLocals | ContainerFlags . PropagatesThisKeyword ;
38603862
38613863 case SyntaxKind . FunctionExpression :
3862- case SyntaxKind . ArrowFunction :
38633864 return ContainerFlags . IsContainer | ContainerFlags . IsControlFlowContainer | ContainerFlags . HasLocals | ContainerFlags . IsFunctionLike | ContainerFlags . IsFunctionExpression ;
38643865
3866+ case SyntaxKind . ArrowFunction :
3867+ return ContainerFlags . IsContainer | ContainerFlags . IsControlFlowContainer | ContainerFlags . HasLocals | ContainerFlags . IsFunctionLike | ContainerFlags . IsFunctionExpression | ContainerFlags . PropagatesThisKeyword ;
3868+
38653869 case SyntaxKind . ModuleBlock :
38663870 return ContainerFlags . IsControlFlowContainer ;
38673871
0 commit comments