@@ -1029,6 +1029,12 @@ namespace ts {
1029
1029
}
1030
1030
}
1031
1031
1032
+ function errorSkippedOn(key: keyof CompilerOptions, location: Node | undefined, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number): Diagnostic {
1033
+ const diagnostic = error(location, message, arg0, arg1, arg2, arg3);
1034
+ diagnostic.skippedOn = key;
1035
+ return diagnostic;
1036
+ }
1037
+
1032
1038
function error(location: Node | undefined, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number): Diagnostic {
1033
1039
const diagnostic = location
1034
1040
? createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3)
@@ -32057,13 +32063,13 @@ namespace ts {
32057
32063
32058
32064
function checkCollisionWithArgumentsInGeneratedCode(node: SignatureDeclaration) {
32059
32065
// no rest parameters \ declaration context \ overload - no codegen impact
32060
- if (languageVersion >= ScriptTarget.ES2015 || compilerOptions.noEmit || !hasRestParameter(node) || node.flags & NodeFlags.Ambient || nodeIsMissing((<FunctionLikeDeclaration>node).body)) {
32066
+ if (languageVersion >= ScriptTarget.ES2015 || !hasRestParameter(node) || node.flags & NodeFlags.Ambient || nodeIsMissing((<FunctionLikeDeclaration>node).body)) {
32061
32067
return;
32062
32068
}
32063
32069
32064
32070
forEach(node.parameters, p => {
32065
32071
if (p.name && !isBindingPattern(p.name) && p.name.escapedText === argumentsSymbol.escapedName) {
32066
- error( p, Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters);
32072
+ errorSkippedOn("noEmit", p, Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters);
32067
32073
}
32068
32074
});
32069
32075
}
@@ -32133,13 +32139,13 @@ namespace ts {
32133
32139
function checkWeakMapCollision(node: Node) {
32134
32140
const enclosingBlockScope = getEnclosingBlockScopeContainer(node);
32135
32141
if (getNodeCheckFlags(enclosingBlockScope) & NodeCheckFlags.ContainsClassWithPrivateIdentifiers) {
32136
- error( node, Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, "WeakMap");
32142
+ errorSkippedOn("noEmit", node, Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, "WeakMap");
32137
32143
}
32138
32144
}
32139
32145
32140
32146
function checkCollisionWithRequireExportsInGeneratedCode(node: Node, name: Identifier) {
32141
32147
// No need to check for require or exports for ES6 modules and later
32142
- if (moduleKind >= ModuleKind.ES2015 || compilerOptions.noEmit ) {
32148
+ if (moduleKind >= ModuleKind.ES2015) {
32143
32149
return;
32144
32150
}
32145
32151
@@ -32156,13 +32162,13 @@ namespace ts {
32156
32162
const parent = getDeclarationContainer(node);
32157
32163
if (parent.kind === SyntaxKind.SourceFile && isExternalOrCommonJsModule(<SourceFile>parent)) {
32158
32164
// If the declaration happens to be in external module, report error that require and exports are reserved keywords
32159
- error( name, Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module,
32165
+ errorSkippedOn("noEmit", name, Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module,
32160
32166
declarationNameToString(name), declarationNameToString(name));
32161
32167
}
32162
32168
}
32163
32169
32164
32170
function checkCollisionWithGlobalPromiseInGeneratedCode(node: Node, name: Identifier): void {
32165
- if (languageVersion >= ScriptTarget.ES2017 || compilerOptions.noEmit || !needCollisionCheckForIdentifier(node, name, "Promise")) {
32171
+ if (languageVersion >= ScriptTarget.ES2017 || !needCollisionCheckForIdentifier(node, name, "Promise")) {
32166
32172
return;
32167
32173
}
32168
32174
@@ -32175,7 +32181,7 @@ namespace ts {
32175
32181
const parent = getDeclarationContainer(node);
32176
32182
if (parent.kind === SyntaxKind.SourceFile && isExternalOrCommonJsModule(<SourceFile>parent) && parent.flags & NodeFlags.HasAsyncFunctions) {
32177
32183
// If the declaration happens to be in external module, report error that Promise is a reserved identifier.
32178
- error( name, Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions,
32184
+ errorSkippedOn("noEmit", name, Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_containing_async_functions,
32179
32185
declarationNameToString(name), declarationNameToString(name));
32180
32186
}
32181
32187
}
@@ -32393,7 +32399,7 @@ namespace ts {
32393
32399
}
32394
32400
checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
32395
32401
checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
32396
- if (!compilerOptions.noEmit && languageVersion < ScriptTarget.ESNext && needCollisionCheckForIdentifier(node, node.name, "WeakMap")) {
32402
+ if (languageVersion < ScriptTarget.ESNext && needCollisionCheckForIdentifier(node, node.name, "WeakMap")) {
32397
32403
potentialWeakMapCollisions.push(node);
32398
32404
}
32399
32405
}
@@ -38316,7 +38322,7 @@ namespace ts {
38316
38322
38317
38323
const moduleKind = getEmitModuleKind(compilerOptions);
38318
38324
38319
- if (moduleKind < ModuleKind.ES2015 && moduleKind !== ModuleKind.System && !compilerOptions.noEmit &&
38325
+ if (moduleKind < ModuleKind.ES2015 && moduleKind !== ModuleKind.System &&
38320
38326
!(node.parent.parent.flags & NodeFlags.Ambient) && hasSyntacticModifier(node.parent.parent, ModifierFlags.Export)) {
38321
38327
checkESModuleMarker(node.name);
38322
38328
}
@@ -38336,7 +38342,7 @@ namespace ts {
38336
38342
function checkESModuleMarker(name: Identifier | BindingPattern): boolean {
38337
38343
if (name.kind === SyntaxKind.Identifier) {
38338
38344
if (idText(name) === "__esModule") {
38339
- return grammarErrorOnNode( name, Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules);
38345
+ return grammarErrorOnNodeSkippedOn("noEmit", name, Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules);
38340
38346
}
38341
38347
}
38342
38348
else {
@@ -38446,6 +38452,15 @@ namespace ts {
38446
38452
return false;
38447
38453
}
38448
38454
38455
+ function grammarErrorOnNodeSkippedOn(key: keyof CompilerOptions, node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
38456
+ const sourceFile = getSourceFileOfNode(node);
38457
+ if (!hasParseDiagnostics(sourceFile)) {
38458
+ errorSkippedOn(key, node, message, arg0, arg1, arg2);
38459
+ return true;
38460
+ }
38461
+ return false;
38462
+ }
38463
+
38449
38464
function grammarErrorOnNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
38450
38465
const sourceFile = getSourceFileOfNode(node);
38451
38466
if (!hasParseDiagnostics(sourceFile)) {
0 commit comments