Skip to content

Commit 827fec6

Browse files
committed
Merge pull request #6200 from Microsoft/reportPreEmitDiagnostics
report pre-emit diagnostics that blocked emit
2 parents 7785e84 + 39605fe commit 827fec6

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

src/compiler/program.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,11 @@ namespace ts {
573573
// If the noEmitOnError flag is set, then check if we have any errors so far. If so,
574574
// immediately bail out. Note that we pass 'undefined' for 'sourceFile' so that we
575575
// get any preEmit diagnostics, not just the ones
576-
if (options.noEmitOnError && getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken).length > 0) {
577-
return { diagnostics: [], sourceMaps: undefined, emitSkipped: true };
576+
if (options.noEmitOnError) {
577+
const preEmitDiagnostics = getPreEmitDiagnostics(program, /*sourceFile:*/ undefined, cancellationToken);
578+
if (preEmitDiagnostics.length > 0) {
579+
return { diagnostics: preEmitDiagnostics, sourceMaps: undefined, emitSkipped: true };
580+
}
578581
}
579582

580583
// Create the emit resolver outside of the "emitTime" tracking code below. That way
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts(4,8): error TS4033: Property 'f' of exported interface has or is using private name 'T'.
2+
3+
4+
==== tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts (1 errors) ====
5+
6+
type T = { x : number }
7+
export interface I {
8+
f: T;
9+
~
10+
!!! error TS4033: Property 'f' of exported interface has or is using private name 'T'.
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// @module: commonjs
2+
// @declaration: true
3+
// @noEmitOnError: true
4+
5+
type T = { x : number }
6+
export interface I {
7+
f: T;
8+
}

0 commit comments

Comments
 (0)