@@ -11119,6 +11119,7 @@ module ts {
1111911119 ? Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
1112011120 : Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module;
1112111121 if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
11122+ // If we hit a module declaration in an illegal context, just bail out to avoid cascading errors.
1112211123 return;
1112311124 }
1112411125
@@ -11235,6 +11236,7 @@ module ts {
1123511236
1123611237 function checkImportDeclaration(node: ImportDeclaration) {
1123711238 if (checkGrammarModuleElementContext(node, Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
11239+ // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors.
1123811240 return;
1123911241 }
1124011242 if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
@@ -11260,6 +11262,7 @@ module ts {
1126011262
1126111263 function checkImportEqualsDeclaration(node: ImportEqualsDeclaration) {
1126211264 if (checkGrammarModuleElementContext(node, Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
11265+ // If we hit an import declaration in an illegal context, just bail out to avoid cascading errors.
1126311266 return;
1126411267 }
1126511268
@@ -11295,6 +11298,7 @@ module ts {
1129511298
1129611299 function checkExportDeclaration(node: ExportDeclaration) {
1129711300 if (checkGrammarModuleElementContext(node, Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) {
11301+ // If we hit an export in an illegal context, just bail out to avoid cascading errors.
1129811302 return;
1129911303 }
1130011304
@@ -11338,6 +11342,7 @@ module ts {
1133811342
1133911343 function checkExportAssignment(node: ExportAssignment) {
1134011344 if (checkGrammarModuleElementContext(node, Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) {
11345+ // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors.
1134111346 return;
1134211347 }
1134311348
0 commit comments