diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 7efecab608..2d66ddfe75 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -54,6 +54,7 @@ namespace ts { /*@internal*/ clean?: boolean; /*@internal*/ watch?: boolean; /*@internal*/ help?: boolean; + preserveWatchOutput?: boolean; } enum BuildResultFlags { @@ -465,6 +466,12 @@ namespace ts { host.reportSolutionBuilderStatus(createCompilerDiagnostic(message, ...args)); } + function reportWatchStatus(message: DiagnosticMessage, ...args: string[]) { + if (hostWithWatch.onWatchStatusChange) { + hostWithWatch.onWatchStatusChange(createCompilerDiagnostic(message, ...args), host.getNewLine(), { preserveWatchOutput: context.options.preserveWatchOutput }); + } + } + function startWatching() { const graph = getGlobalDependencyGraph()!; if (!graph.buildQueue) { @@ -500,6 +507,7 @@ namespace ts { } function invalidateProjectAndScheduleBuilds(resolved: ResolvedConfigFileName) { + reportWatchStatus(Diagnostics.File_change_detected_Starting_incremental_compilation); invalidateProject(resolved); if (!hostWithWatch.setTimeout) { return; @@ -1038,6 +1046,7 @@ namespace ts { } function buildAllProjects(): ExitStatus { + if (context.options.watch) { reportWatchStatus(Diagnostics.Starting_compilation_in_watch_mode); } const graph = getGlobalDependencyGraph(); if (graph === undefined) return ExitStatus.DiagnosticsPresent_OutputsSkipped; diff --git a/src/tsc/tsc.ts b/src/tsc/tsc.ts index 5be8660187..1685dfc344 100644 --- a/src/tsc/tsc.ts +++ b/src/tsc/tsc.ts @@ -211,7 +211,13 @@ namespace ts { category: Diagnostics.Command_line_Options, description: Diagnostics.Watch_input_files, type: "boolean" - } + }, + { + name: "preserveWatchOutput", + type: "boolean", + category: Diagnostics.Command_line_Options, + description: Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen, + }, ]; let buildOptionNameMap: OptionNameMap | undefined; const returnBuildOptionNameMap = () => (buildOptionNameMap || (buildOptionNameMap = createOptionNameMap(buildOpts)));