Skip to content

Commit 2cb8493

Browse files
committed
Change checkGrammarModuleElementContext to return true if it gives an error
1 parent 635a773 commit 2cb8493

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/compiler/checker.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11118,7 +11118,7 @@ module ts {
1111811118
let contextErrorMessage = isAmbientExternalModule
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;
11121-
if (!checkGrammarModuleElementContext(node, contextErrorMessage)) {
11121+
if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
1112211122
return;
1112311123
}
1112411124

@@ -11234,7 +11234,7 @@ module ts {
1123411234
}
1123511235

1123611236
function checkImportDeclaration(node: ImportDeclaration) {
11237-
if (!checkGrammarModuleElementContext(node, Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
11237+
if (checkGrammarModuleElementContext(node, Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
1123811238
return;
1123911239
}
1124011240
if (!checkGrammarImportDeclarationNameInStrictMode(node) && !checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
@@ -11259,7 +11259,7 @@ module ts {
1125911259
}
1126011260

1126111261
function checkImportEqualsDeclaration(node: ImportEqualsDeclaration) {
11262-
if (!checkGrammarModuleElementContext(node, Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
11262+
if (checkGrammarModuleElementContext(node, Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
1126311263
return;
1126411264
}
1126511265

@@ -11294,7 +11294,7 @@ module ts {
1129411294
}
1129511295

1129611296
function checkExportDeclaration(node: ExportDeclaration) {
11297-
if (!checkGrammarModuleElementContext(node, Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) {
11297+
if (checkGrammarModuleElementContext(node, Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) {
1129811298
return;
1129911299
}
1130011300

@@ -11325,11 +11325,8 @@ module ts {
1132511325

1132611326
function checkGrammarModuleElementContext(node: Statement, errorMessage: DiagnosticMessage): boolean {
1132711327
if (node.parent.kind !== SyntaxKind.SourceFile && node.parent.kind !== SyntaxKind.ModuleBlock && node.parent.kind !== SyntaxKind.ModuleDeclaration) {
11328-
grammarErrorOnFirstToken(node, errorMessage);
11329-
return false;
11328+
return grammarErrorOnFirstToken(node, errorMessage);
1133011329
}
11331-
11332-
return true;
1133311330
}
1133411331

1133511332
function checkExportSpecifier(node: ExportSpecifier) {
@@ -11340,7 +11337,7 @@ module ts {
1134011337
}
1134111338

1134211339
function checkExportAssignment(node: ExportAssignment) {
11343-
if (!checkGrammarModuleElementContext(node, Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) {
11340+
if (checkGrammarModuleElementContext(node, Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) {
1134411341
return;
1134511342
}
1134611343

0 commit comments

Comments
 (0)