@@ -1013,6 +1013,12 @@ namespace ts {
10131013 }
10141014 }
10151015
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+
10161022 function error(location: Node | undefined, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number): Diagnostic {
10171023 const diagnostic = location
10181024 ? createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3)
@@ -32030,13 +32036,13 @@ namespace ts {
3203032036
3203132037 function checkCollisionWithArgumentsInGeneratedCode(node: SignatureDeclaration) {
3203232038 // 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)) {
3203432040 return;
3203532041 }
3203632042
3203732043 forEach(node.parameters, p => {
3203832044 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);
3204032046 }
3204132047 });
3204232048 }
@@ -32106,13 +32112,13 @@ namespace ts {
3210632112 function checkWeakMapCollision(node: Node) {
3210732113 const enclosingBlockScope = getEnclosingBlockScopeContainer(node);
3210832114 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");
3211032116 }
3211132117 }
3211232118
3211332119 function checkCollisionWithRequireExportsInGeneratedCode(node: Node, name: Identifier) {
3211432120 // 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) {
3211632122 return;
3211732123 }
3211832124
@@ -32129,13 +32135,13 @@ namespace ts {
3212932135 const parent = getDeclarationContainer(node);
3213032136 if (parent.kind === SyntaxKind.SourceFile && isExternalOrCommonJsModule(<SourceFile>parent)) {
3213132137 // 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,
3213332139 declarationNameToString(name), declarationNameToString(name));
3213432140 }
3213532141 }
3213632142
3213732143 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")) {
3213932145 return;
3214032146 }
3214132147
@@ -32148,7 +32154,7 @@ namespace ts {
3214832154 const parent = getDeclarationContainer(node);
3214932155 if (parent.kind === SyntaxKind.SourceFile && isExternalOrCommonJsModule(<SourceFile>parent) && parent.flags & NodeFlags.HasAsyncFunctions) {
3215032156 // 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,
3215232158 declarationNameToString(name), declarationNameToString(name));
3215332159 }
3215432160 }
@@ -32366,7 +32372,7 @@ namespace ts {
3236632372 }
3236732373 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
3236832374 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")) {
3237032376 potentialWeakMapCollisions.push(node);
3237132377 }
3237232378 }
@@ -38267,7 +38273,7 @@ namespace ts {
3826738273
3826838274 const moduleKind = getEmitModuleKind(compilerOptions);
3826938275
38270- if (moduleKind < ModuleKind.ES2015 && moduleKind !== ModuleKind.System && !compilerOptions.noEmit &&
38276+ if (moduleKind < ModuleKind.ES2015 && moduleKind !== ModuleKind.System &&
3827138277 !(node.parent.parent.flags & NodeFlags.Ambient) && hasSyntacticModifier(node.parent.parent, ModifierFlags.Export)) {
3827238278 checkESModuleMarker(node.name);
3827338279 }
@@ -38287,7 +38293,7 @@ namespace ts {
3828738293 function checkESModuleMarker(name: Identifier | BindingPattern): boolean {
3828838294 if (name.kind === SyntaxKind.Identifier) {
3828938295 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);
3829138297 }
3829238298 }
3829338299 else {
@@ -38397,6 +38403,15 @@ namespace ts {
3839738403 return false;
3839838404 }
3839938405
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+
3840038415 function grammarErrorOnNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
3840138416 const sourceFile = getSourceFileOfNode(node);
3840238417 if (!hasParseDiagnostics(sourceFile)) {
0 commit comments