File tree Expand file tree Collapse file tree 5 files changed +48
-1
lines changed Expand file tree Collapse file tree 5 files changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,13 @@ namespace ts {
5555 paramType : Diagnostics . FILE_OR_DIRECTORY ,
5656 description : Diagnostics . Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json ,
5757 } ,
58+ {
59+ name : "preserveWatchOutput" ,
60+ type : "boolean" ,
61+ showInSimplifiedHelpView : false ,
62+ category : Diagnostics . Command_line_Options ,
63+ description : Diagnostics . Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen ,
64+ } ,
5865 {
5966 name : "pretty" ,
6067 type : "boolean" ,
Original file line number Diff line number Diff line change 34553455 "category" : " Message" ,
34563456 "code" : 6190
34573457 },
3458+ "Whether to keep outdated console output in watch mode instead of clearing the screen." : {
3459+ "category" : " Message" ,
3460+ "code" : 6191
3461+ },
34583462 "Variable '{0}' implicitly has an '{1}' type." : {
34593463 "category" : " Error" ,
34603464 "code" : 7005
Original file line number Diff line number Diff line change @@ -4014,6 +4014,7 @@ namespace ts {
40144014 /*@internal */ plugins ?: PluginImport [ ] ;
40154015 preserveConstEnums ?: boolean ;
40164016 preserveSymlinks ?: boolean ;
4017+ /* @internal */ preserveWatchOutput ?: boolean ;
40174018 project ?: string ;
40184019 /* @internal */ pretty ?: DiagnosticStyle ;
40194020 reactNamespace ?: string ;
Original file line number Diff line number Diff line change @@ -513,7 +513,7 @@ namespace ts {
513513 }
514514
515515 function clearHostScreen ( ) {
516- if ( watchingHost . system . clearScreen ) {
516+ if ( watchingHost . system . clearScreen && ! compilerOptions . preserveWatchOutput ) {
517517 watchingHost . system . clearScreen ( ) ;
518518 }
519519 }
Original file line number Diff line number Diff line change @@ -2100,6 +2100,21 @@ declare module "fs" {
21002100 host . checkScreenClears ( 1 ) ;
21012101 } ) ;
21022102
2103+ it ( "doesn't clear the console when it starts if --preserveWatchOutput is true" , ( ) => {
2104+ const file = {
2105+ path : "f.ts" ,
2106+ content : ""
2107+ } ;
2108+ const host = createWatchedSystem ( [ file ] ) ;
2109+
2110+ createWatchModeWithoutConfigFile ( [ file . path ] , host , {
2111+ preserveWatchOutput : true ,
2112+ } ) ;
2113+ host . runQueuedTimeoutCallbacks ( ) ;
2114+
2115+ host . checkScreenClears ( 0 ) ;
2116+ } ) ;
2117+
21032118 it ( "clears the console on recompile" , ( ) => {
21042119 const file = {
21052120 path : "f.ts" ,
@@ -2117,5 +2132,25 @@ declare module "fs" {
21172132
21182133 host . checkScreenClears ( 2 ) ;
21192134 } ) ;
2135+
2136+ it ( "doesn't clear the console on recompile if --preserveWatchOutput is true" , ( ) => {
2137+ const file = {
2138+ path : "f.ts" ,
2139+ content : ""
2140+ } ;
2141+ const host = createWatchedSystem ( [ file ] ) ;
2142+ createWatchModeWithoutConfigFile ( [ file . path ] , host , {
2143+ preserveWatchOutput : true ,
2144+ } ) ;
2145+
2146+ const modifiedFile = {
2147+ ...file ,
2148+ content : "//"
2149+ } ;
2150+ host . reloadFS ( [ modifiedFile ] ) ;
2151+ host . runQueuedTimeoutCallbacks ( ) ;
2152+
2153+ host . checkScreenClears ( 0 ) ;
2154+ } ) ;
21202155 } ) ;
21212156}
You can’t perform that action at this time.
0 commit comments