Skip to content

Commit

Permalink
Merge pull request #7106 from Microsoft/Fix7093
Browse files Browse the repository at this point in the history
Do not report all diagnostics in Program.emit(),
  • Loading branch information
mhegazy committed Feb 17, 2016
2 parents edae7c3 + 1f59939 commit 01ea1a8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,18 @@ namespace ts {
// immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we
// get any preEmit diagnostics, not just the ones
if (options.noEmitOnError) {
const preEmitDiagnostics = getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken);
if (preEmitDiagnostics.length > 0) {
return { diagnostics: preEmitDiagnostics, sourceMaps: undefined, emitSkipped: true };
const diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(
program.getSyntacticDiagnostics(sourceFile, cancellationToken),
program.getGlobalDiagnostics(cancellationToken),
program.getSemanticDiagnostics(sourceFile, cancellationToken));
let declarationDiagnostics: Diagnostic[] = [];

if (diagnostics.length === 0 && program.getCompilerOptions().declaration) {
declarationDiagnostics = program.getDeclarationDiagnostics(/*sourceFile*/ undefined, cancellationToken);
}

if (diagnostics.length > 0 || declarationDiagnostics.length > 0) {
return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emitSkipped: true };
}
}

Expand Down

0 comments on commit 01ea1a8

Please sign in to comment.