From 39605fe5f823c0c987d57252ed029cee38d0e54d Mon Sep 17 00:00:00 2001 From: vladima Date: Mon, 21 Dec 2015 21:43:51 -0800 Subject: [PATCH] report pre-emit diagnostics that blocked emit --- src/compiler/program.ts | 7 +++++-- .../DeclarationErrorsNoEmitOnError.errors.txt | 11 +++++++++++ .../cases/compiler/DeclarationErrorsNoEmitOnError.ts | 8 ++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/DeclarationErrorsNoEmitOnError.errors.txt create mode 100644 tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts diff --git a/src/compiler/program.ts b/src/compiler/program.ts index da6f7ab0ee7..d5c8b9f913f 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -573,8 +573,11 @@ namespace ts { // If the noEmitOnError flag is set, then check if we have any errors so far. If so, // immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we // get any preEmit diagnostics, not just the ones - if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) { - return { diagnostics: [], sourceMaps: undefined, emitSkipped: true }; + if (options.noEmitOnError) { + const preEmitDiagnostics = getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken); + if (preEmitDiagnostics.length > 0) { + return { diagnostics: preEmitDiagnostics, sourceMaps: undefined, emitSkipped: true }; + } } // Create the emit resolver outside of the "emitTime" tracking code below. That way diff --git a/tests/baselines/reference/DeclarationErrorsNoEmitOnError.errors.txt b/tests/baselines/reference/DeclarationErrorsNoEmitOnError.errors.txt new file mode 100644 index 00000000000..1f442e98d12 --- /dev/null +++ b/tests/baselines/reference/DeclarationErrorsNoEmitOnError.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts(4,8): error TS4033: Property 'f' of exported interface has or is using private name 'T'. + + +==== tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts (1 errors) ==== + + type T = { x : number } + export interface I { + f: T; + ~ +!!! error TS4033: Property 'f' of exported interface has or is using private name 'T'. + } \ No newline at end of file diff --git a/tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts b/tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts new file mode 100644 index 00000000000..ef8711e7110 --- /dev/null +++ b/tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts @@ -0,0 +1,8 @@ +// @module: commonjs +// @declaration: true +// @noEmitOnError: true + +type T = { x : number } +export interface I { + f: T; +} \ No newline at end of file