diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index e8fae71597d..35692531d05 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -302,9 +302,7 @@ namespace ts { // There is no extra check needed since we can just rely on the program to decide emit const builder = createBuilder({ getCanonicalFileName, computeHash }); - if (watchingHost.system.clearScreen) { - watchingHost.system.clearScreen(); - } + clearHostScreen(); reportWatchDiagnostic(createCompilerDiagnostic(Diagnostics.Starting_compilation_in_watch_mode)); synchronizeProgram(); @@ -496,10 +494,14 @@ namespace ts { scheduleProgramUpdate(); } - function updateProgram() { + function clearHostScreen() { if (watchingHost.system.clearScreen) { watchingHost.system.clearScreen(); } + } + + function updateProgram() { + clearHostScreen(); timerToUpdateProgram = undefined; reportWatchDiagnostic(createCompilerDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation)); diff --git a/src/harness/unittests/tscWatchMode.ts b/src/harness/unittests/tscWatchMode.ts index 8c89c7564f7..e5f994b9fe7 100644 --- a/src/harness/unittests/tscWatchMode.ts +++ b/src/harness/unittests/tscWatchMode.ts @@ -117,6 +117,10 @@ namespace ts.tscWatch { index++; }); if (!skipWaiting) { + if (errorsPosition === ExpectedOutputErrorsPosition.BeforeCompilationStarts) { + assertWatchDiagnosticAt(host, index, ts.Diagnostics.Starting_compilation_in_watch_mode); + index += 1; + } assertWatchDiagnosticAt(host, index, Diagnostics.Compilation_complete_Watching_for_file_changes); } host.clearOutput();