@@ -11119,6 +11119,7 @@ module ts {
11119
11119
? Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
11120
11120
: Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module;
11121
11121
if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
11122
+ // If we hit a module declaration in an illegal context, just bail out to avoid cascading errors.
11122
11123
return;
11123
11124
}
11124
11125
@@ -11235,6 +11236,7 @@ module ts {
11235
11236
11236
11237
function checkImportDeclaration(node: ImportDeclaration) {
11237
11238
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.
11238
11240
return;
11239
11241
}
11240
11242
if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
@@ -11260,6 +11262,7 @@ module ts {
11260
11262
11261
11263
function checkImportEqualsDeclaration(node: ImportEqualsDeclaration) {
11262
11264
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.
11263
11266
return;
11264
11267
}
11265
11268
@@ -11295,6 +11298,7 @@ module ts {
11295
11298
11296
11299
function checkExportDeclaration(node: ExportDeclaration) {
11297
11300
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.
11298
11302
return;
11299
11303
}
11300
11304
@@ -11338,6 +11342,7 @@ module ts {
11338
11342
11339
11343
function checkExportAssignment(node: ExportAssignment) {
11340
11344
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.
11341
11346
return;
11342
11347
}
11343
11348
0 commit comments