@@ -31,8 +31,11 @@ namespace ts {
3131 } ;
3232 }
3333
34- function clearScreenIfNotWatchingForFileChanges ( system : System , diagnostic : Diagnostic ) {
35- if ( system . clearScreen && diagnostic . code !== Diagnostics . Compilation_complete_Watching_for_file_changes . code ) {
34+ function clearScreenIfNotWatchingForFileChanges ( system : System , diagnostic : Diagnostic , options : CompilerOptions ) {
35+ if ( system . clearScreen &&
36+ diagnostic . code !== Diagnostics . Compilation_complete_Watching_for_file_changes . code &&
37+ ! options . extendedDiagnostics &&
38+ ! options . diagnostics ) {
3639 system . clearScreen ( ) ;
3740 }
3841 }
@@ -42,18 +45,18 @@ namespace ts {
4245 */
4346 export function createWatchStatusReporter ( system : System , pretty ?: boolean ) : WatchStatusReporter {
4447 return pretty ?
45- ( diagnostic : Diagnostic , newLine : string ) => {
46- clearScreenIfNotWatchingForFileChanges ( system , diagnostic ) ;
47- let output = `[${ formatColorAndReset ( new Date ( ) . toLocaleTimeString ( ) , ForegroundColorEscapeSequences . Grey ) } ] ` ;
48- output += `${ flattenDiagnosticMessageText ( diagnostic . messageText , system . newLine ) } ${ newLine + newLine + newLine } ` ;
49- system . write ( output ) ;
50- } :
51- ( diagnostic : Diagnostic , newLine : string ) => {
52- clearScreenIfNotWatchingForFileChanges ( system , diagnostic ) ;
53- let output = new Date ( ) . toLocaleTimeString ( ) + " - " ;
54- output += `${ flattenDiagnosticMessageText ( diagnostic . messageText , system . newLine ) } ${ newLine + newLine + newLine } ` ;
55- system . write ( output ) ;
56- } ;
48+ ( diagnostic , newLine , options ) => {
49+ clearScreenIfNotWatchingForFileChanges ( system , diagnostic , options ) ;
50+ let output = `[${ formatColorAndReset ( new Date ( ) . toLocaleTimeString ( ) , ForegroundColorEscapeSequences . Grey ) } ] ` ;
51+ output += `${ flattenDiagnosticMessageText ( diagnostic . messageText , system . newLine ) } ${ newLine + newLine + newLine } ` ;
52+ system . write ( output ) ;
53+ } :
54+ ( diagnostic , newLine , options ) => {
55+ clearScreenIfNotWatchingForFileChanges ( system , diagnostic , options ) ;
56+ let output = new Date ( ) . toLocaleTimeString ( ) + " - " ;
57+ output += `${ flattenDiagnosticMessageText ( diagnostic . messageText , system . newLine ) } ${ newLine + newLine + newLine } ` ;
58+ system . write ( output ) ;
59+ } ;
5760 }
5861
5962 /**
@@ -254,7 +257,7 @@ namespace ts {
254257
255258namespace ts {
256259 export type DiagnosticReporter = ( diagnostic : Diagnostic ) => void ;
257- export type WatchStatusReporter = ( diagnostic : Diagnostic , newLine : string ) => void ;
260+ export type WatchStatusReporter = ( diagnostic : Diagnostic , newLine : string , options : CompilerOptions ) => void ;
258261 export type CreateProgram < T extends BuilderProgram > = ( rootNames : ReadonlyArray < string > , options : CompilerOptions , host ?: CompilerHost , oldProgram ?: T ) => T ;
259262 export interface WatchCompilerHost < T extends BuilderProgram > {
260263 /**
@@ -264,7 +267,7 @@ namespace ts {
264267 /** If provided, callback to invoke after every new program creation */
265268 afterProgramCreate ?( program : T ) : void ;
266269 /** If provided, called with Diagnostic message that informs about change in watch status */
267- onWatchStatusChange ?( diagnostic : Diagnostic , newLine : string ) : void ;
270+ onWatchStatusChange ?( diagnostic : Diagnostic , newLine : string , options : CompilerOptions ) : void ;
268271
269272 // Only for testing
270273 /*@internal */
@@ -725,7 +728,7 @@ namespace ts {
725728
726729 function reportWatchDiagnostic ( message : DiagnosticMessage ) {
727730 if ( host . onWatchStatusChange ) {
728- host . onWatchStatusChange ( createCompilerDiagnostic ( message ) , newLine ) ;
731+ host . onWatchStatusChange ( createCompilerDiagnostic ( message ) , newLine , compilerOptions ) ;
729732 }
730733 }
731734
0 commit comments