@@ -1029,6 +1029,12 @@ namespace ts {
10291029 }
10301030 }
10311031
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+
10321038 function error(location: Node | undefined, message: DiagnosticMessage, arg0?: string | number, arg1?: string | number, arg2?: string | number, arg3?: string | number): Diagnostic {
10331039 const diagnostic = location
10341040 ? createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3)
@@ -32057,13 +32063,13 @@ namespace ts {
3205732063
3205832064 function checkCollisionWithArgumentsInGeneratedCode(node: SignatureDeclaration) {
3205932065 // 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)) {
3206132067 return;
3206232068 }
3206332069
3206432070 forEach(node.parameters, p => {
3206532071 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);
3206732073 }
3206832074 });
3206932075 }
@@ -32133,13 +32139,13 @@ namespace ts {
3213332139 function checkWeakMapCollision(node: Node) {
3213432140 const enclosingBlockScope = getEnclosingBlockScopeContainer(node);
3213532141 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");
3213732143 }
3213832144 }
3213932145
3214032146 function checkCollisionWithRequireExportsInGeneratedCode(node: Node, name: Identifier) {
3214132147 // 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) {
3214332149 return;
3214432150 }
3214532151
@@ -32156,13 +32162,13 @@ namespace ts {
3215632162 const parent = getDeclarationContainer(node);
3215732163 if (parent.kind === SyntaxKind.SourceFile && isExternalOrCommonJsModule(<SourceFile>parent)) {
3215832164 // 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,
3216032166 declarationNameToString(name), declarationNameToString(name));
3216132167 }
3216232168 }
3216332169
3216432170 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")) {
3216632172 return;
3216732173 }
3216832174
@@ -32175,7 +32181,7 @@ namespace ts {
3217532181 const parent = getDeclarationContainer(node);
3217632182 if (parent.kind === SyntaxKind.SourceFile && isExternalOrCommonJsModule(<SourceFile>parent) && parent.flags & NodeFlags.HasAsyncFunctions) {
3217732183 // 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,
3217932185 declarationNameToString(name), declarationNameToString(name));
3218032186 }
3218132187 }
@@ -32393,7 +32399,7 @@ namespace ts {
3239332399 }
3239432400 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
3239532401 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")) {
3239732403 potentialWeakMapCollisions.push(node);
3239832404 }
3239932405 }
@@ -38316,7 +38322,7 @@ namespace ts {
3831638322
3831738323 const moduleKind = getEmitModuleKind(compilerOptions);
3831838324
38319- if (moduleKind < ModuleKind.ES2015 && moduleKind !== ModuleKind.System && !compilerOptions.noEmit &&
38325+ if (moduleKind < ModuleKind.ES2015 && moduleKind !== ModuleKind.System &&
3832038326 !(node.parent.parent.flags & NodeFlags.Ambient) && hasSyntacticModifier(node.parent.parent, ModifierFlags.Export)) {
3832138327 checkESModuleMarker(node.name);
3832238328 }
@@ -38336,7 +38342,7 @@ namespace ts {
3833638342 function checkESModuleMarker(name: Identifier | BindingPattern): boolean {
3833738343 if (name.kind === SyntaxKind.Identifier) {
3833838344 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);
3834038346 }
3834138347 }
3834238348 else {
@@ -38446,6 +38452,15 @@ namespace ts {
3844638452 return false;
3844738453 }
3844838454
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+
3844938464 function grammarErrorOnNode(node: Node, message: DiagnosticMessage, arg0?: any, arg1?: any, arg2?: any): boolean {
3845038465 const sourceFile = getSourceFileOfNode(node);
3845138466 if (!hasParseDiagnostics(sourceFile)) {
0 commit comments