From 1f599398e1247730e9dab756bcf3ded56b86b163 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 16 Feb 2016 16:35:13 -0800 Subject: [PATCH] Do not report all declarations in Program.emit, only declaration diagnostics --- src/compiler/program.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 4ffaf52e93d..d7e06a4e550 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -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 }; } }