Skip to content

Commit 01ea1a8

Browse files
committed
Merge pull request #7106 from Microsoft/Fix7093
Do not report all diagnostics in Program.emit(),
2 parents edae7c3 + 1f59939 commit 01ea1a8

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/compiler/program.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,9 +609,18 @@ namespace ts {
609609
// immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we
610610
// get any preEmit diagnostics, not just the ones
611611
if (options.noEmitOnError) {
612-
const preEmitDiagnostics = getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken);
613-
if (preEmitDiagnostics.length > 0) {
614-
return { diagnostics: preEmitDiagnostics, sourceMaps: undefined, emitSkipped: true };
612+
const diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(
613+
program.getSyntacticDiagnostics(sourceFile, cancellationToken),
614+
program.getGlobalDiagnostics(cancellationToken),
615+
program.getSemanticDiagnostics(sourceFile, cancellationToken));
616+
let declarationDiagnostics: Diagnostic[] = [];
617+
618+
if (diagnostics.length === 0 && program.getCompilerOptions().declaration) {
619+
declarationDiagnostics = program.getDeclarationDiagnostics(/*sourceFile*/ undefined, cancellationToken);
620+
}
621+
622+
if (diagnostics.length > 0 || declarationDiagnostics.length > 0) {
623+
return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emitSkipped: true };
615624
}
616625
}
617626

0 commit comments

Comments
 (0)