@@ -1013,6 +1013,12 @@ namespace ts {
1013
1013
}
1014
1014
}
1015
1015
1016
+ function errorSkippedOn(key: keyof CompilerOptions, location: Node | undefined, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number): Diagnostic {
1017
+ const diagnostic = error(location, message, arg0, arg1, arg2, arg3);
1018
+ diagnostic.skippedOn = key;
1019
+ return diagnostic;
1020
+ }
1021
+
1016
1022
function error(location: Node | undefined, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number): Diagnostic {
1017
1023
const diagnostic = location
1018
1024
? createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3)
@@ -32030,13 +32036,13 @@ namespace ts {
32030
32036
32031
32037
function checkCollisionWithArgumentsInGeneratedCode(node: SignatureDeclaration) {
32032
32038
// no rest parameters \ declaration context \ overload - no codegen impact
32033
- if (languageVersion >= ScriptTarget.ES2015 || compilerOptions.noEmit || !hasRestParameter(node) || node.flags & NodeFlags.Ambient || nodeIsMissing((<FunctionLikeDeclaration>node).body)) {
32039
+ if (languageVersion >= ScriptTarget.ES2015 || !hasRestParameter(node) || node.flags & NodeFlags.Ambient || nodeIsMissing((<FunctionLikeDeclaration>node).body)) {
32034
32040
return;
32035
32041
}
32036
32042
32037
32043
forEach(node.parameters, p => {
32038
32044
if (p.name && !isBindingPattern(p.name) && p.name.escapedText === argumentsSymbol.escapedName) {
32039
- error( p, Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters);
32045
+ errorSkippedOn("noEmit", p, Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters);
32040
32046
}
32041
32047
});
32042
32048
}
@@ -32106,13 +32112,13 @@ namespace ts {
32106
32112
function checkWeakMapCollision(node: Node) {
32107
32113
const enclosingBlockScope = getEnclosingBlockScopeContainer(node);
32108
32114
if (getNodeCheckFlags(enclosingBlockScope) & NodeCheckFlags.ContainsClassWithPrivateIdentifiers) {
32109
- error( node, Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, "WeakMap");
32115
+ errorSkippedOn("noEmit", node, Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, "WeakMap");
32110
32116
}
32111
32117
}
32112
32118
32113
32119
function checkCollisionWithRequireExportsInGeneratedCode(node: Node, name: Identifier) {
32114
32120
// No need to check for require or exports for ES6 modules and later
32115
- if (moduleKind >= ModuleKind.ES2015 || compilerOptions.noEmit ) {
32121
+ if (moduleKind >= ModuleKind.ES2015) {
32116
32122
return;
32117
32123
}
32118
32124
@@ -32129,13 +32135,13 @@ namespace ts {
32129
32135
const parent = getDeclarationContainer(node);
32130
32136
if (parent.kind === SyntaxKind.SourceFile && isExternalOrCommonJsModule(<SourceFile>parent)) {
32131
32137
// If the declaration happens to be in external module, report error that require and exports are reserved keywords
32132
- error( name, Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module,
32138
+ errorSkippedOn("noEmit", name, Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module,
32133
32139
declarationNameToString(name), declarationNameToString(name));
32134
32140
}
32135
32141
}
32136
32142
32137
32143
function checkCollisionWithGlobalPromiseInGeneratedCode(node: Node, name: Identifier): void {
32138
- if (languageVersion >= ScriptTarget.ES2017 || compilerOptions.noEmit || !needCollisionCheckForIdentifier(node, name, "Promise")) {
32144
+ if (languageVersion >= ScriptTarget.ES2017 || !needCollisionCheckForIdentifier(node, name, "Promise")) {
32139
32145
return;
32140
32146
}
32141
32147
@@ -32148,7 +32154,7 @@ namespace ts {
32148
32154
const parent = getDeclarationContainer(node);
32149
32155
if (parent.kind === SyntaxKind.SourceFile && isExternalOrCommonJsModule(<SourceFile>parent) && parent.flags & NodeFlags.HasAsyncFunctions) {
32150
32156
// If the declaration happens to be in external module, report error that Promise is a reserved identifier.
32151
- error( name, Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions,
32157
+ errorSkippedOn("noEmit", name, Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions,
32152
32158
declarationNameToString(name), declarationNameToString(name));
32153
32159
}
32154
32160
}
@@ -32366,7 +32372,7 @@ namespace ts {
32366
32372
}
32367
32373
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
32368
32374
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
32369
- if (!compilerOptions.noEmit && languageVersion < ScriptTarget.ESNext && needCollisionCheckForIdentifier(node, node.name, "WeakMap")) {
32375
+ if (languageVersion < ScriptTarget.ESNext && needCollisionCheckForIdentifier(node, node.name, "WeakMap")) {
32370
32376
potentialWeakMapCollisions.push(node);
32371
32377
}
32372
32378
}
@@ -38267,7 +38273,7 @@ namespace ts {
38267
38273
38268
38274
const moduleKind = getEmitModuleKind(compilerOptions);
38269
38275
38270
- if (moduleKind < ModuleKind.ES2015 && moduleKind !== ModuleKind.System && !compilerOptions.noEmit &&
38276
+ if (moduleKind < ModuleKind.ES2015 && moduleKind !== ModuleKind.System &&
38271
38277
!(node.parent.parent.flags & NodeFlags.Ambient) && hasSyntacticModifier(node.parent.parent, ModifierFlags.Export)) {
38272
38278
checkESModuleMarker(node.name);
38273
38279
}
@@ -38287,7 +38293,7 @@ namespace ts {
38287
38293
function checkESModuleMarker(name: Identifier | BindingPattern): boolean {
38288
38294
if (name.kind === SyntaxKind.Identifier) {
38289
38295
if (idText(name) === "__esModule") {
38290
- return grammarErrorOnNode( name, Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules);
38296
+ return grammarErrorOnNodeSkippedOn("noEmit", name, Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules);
38291
38297
}
38292
38298
}
38293
38299
else {
@@ -38397,6 +38403,15 @@ namespace ts {
38397
38403
return false;
38398
38404
}
38399
38405
38406
+ function grammarErrorOnNodeSkippedOn(key: keyof CompilerOptions, node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
38407
+ const sourceFile = getSourceFileOfNode(node);
38408
+ if (!hasParseDiagnostics(sourceFile)) {
38409
+ errorSkippedOn(key, node, message, arg0, arg1, arg2);
38410
+ return true;
38411
+ }
38412
+ return false;
38413
+ }
38414
+
38400
38415
function grammarErrorOnNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
38401
38416
const sourceFile = getSourceFileOfNode(node);
38402
38417
if (!hasParseDiagnostics(sourceFile)) {
0 commit comments