diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index 530eb4d31e0..f53f01e3eb2 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -127,7 +127,7 @@ namespace ts { /** * Helper that emit files, report diagnostics and lists emitted and/or source files depending on compiler options */ - export function emitFilesAndReportErrors(program: ProgramToEmitFilesAndReportErrors, reportDiagnostic: DiagnosticReporter, reportSummary?: ReportEmitErrorSummary, writeFileName?: (s: string) => void) { + export function emitFilesAndReportErrors(program: ProgramToEmitFilesAndReportErrors, reportDiagnostic: DiagnosticReporter, writeFileName?: (s: string) => void, reportSummary?: ReportEmitErrorSummary) { // First get and report any syntactic errors. const diagnostics = program.getConfigFileParsingDiagnostics().slice(); const configFileParsingDiagnosticsLength = diagnostics.length; @@ -242,7 +242,7 @@ namespace ts { } }; - emitFilesAndReportErrors(builderProgram, reportDiagnostic, reportSummary, writeFileName); + emitFilesAndReportErrors(builderProgram, reportDiagnostic, writeFileName, reportSummary); } } diff --git a/src/harness/unittests/tscWatchMode.ts b/src/harness/unittests/tscWatchMode.ts index 9965489ca71..99bad3e3091 100644 --- a/src/harness/unittests/tscWatchMode.ts +++ b/src/harness/unittests/tscWatchMode.ts @@ -128,6 +128,12 @@ namespace ts.tscWatch { } } + function createErrorsFoundCompilerDiagnostic(errors: ReadonlyArray) { + return errors.length === 1 + ? createCompilerDiagnostic(Diagnostics.Found_1_error) + : createCompilerDiagnostic(Diagnostics.Found_0_errors, errors.length); + } + function checkOutputErrorsInitial(host: WatchedSystem, errors: ReadonlyArray, disableConsoleClears?: boolean, logsBeforeErrors?: string[]) { checkOutputErrors( host, @@ -136,9 +142,7 @@ namespace ts.tscWatch { logsBeforeErrors, errors, disableConsoleClears, - errors.length === 1 - ? createCompilerDiagnostic(Diagnostics.Found_1_error) - : createCompilerDiagnostic(Diagnostics.Found_0_errors, errors.length), + createErrorsFoundCompilerDiagnostic(errors), createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes)); } @@ -150,9 +154,7 @@ namespace ts.tscWatch { logsBeforeErrors, errors, disableConsoleClears, - errors.length === 1 - ? createCompilerDiagnostic(Diagnostics.Found_1_error) - : createCompilerDiagnostic(Diagnostics.Found_0_errors, errors.length), + createErrorsFoundCompilerDiagnostic(errors), createCompilerDiagnostic(Diagnostics.Compilation_complete_Watching_for_file_changes)); }