diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 46c74816921..7b059833be0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15473,7 +15473,7 @@ namespace ts { // With noImplicitThis, functions may not reference 'this' if it has type 'any' error( node, - capturedByArrowFunction ? + capturedByArrowFunction && container.kind === SyntaxKind.SourceFile ? Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this_which_implicitly_has_type_any : Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation); }