@@ -44,6 +44,24 @@ namespace ts {
4444 }
4545 }
4646
47+ /** @internal */
48+ const screenStartingMessageCodes : number [ ] = [
49+ Diagnostics . Starting_compilation_in_watch_mode . code ,
50+ Diagnostics . File_change_detected_Starting_incremental_compilation . code ,
51+ ] ;
52+
53+ function getPlainDiagnosticPrecedingNewLines ( diagnostic : Diagnostic , newLine : string ) : string {
54+ return contains ( screenStartingMessageCodes , diagnostic . code )
55+ ? ""
56+ : newLine ;
57+ }
58+
59+ function getPlainDiagnosticFollowingNewLines ( diagnostic : Diagnostic , newLine : string ) : string {
60+ return contains ( screenStartingMessageCodes , diagnostic . code )
61+ ? newLine + newLine
62+ : newLine ;
63+ }
64+
4765 /**
4866 * Create a function that reports watch status by writing to the system and handles the formating of the diagnostic
4967 */
@@ -52,13 +70,13 @@ namespace ts {
5270 ( diagnostic , newLine , options ) => {
5371 clearScreenIfNotWatchingForFileChanges ( system , diagnostic , options ) ;
5472 let output = `[${ formatColorAndReset ( new Date ( ) . toLocaleTimeString ( ) , ForegroundColorEscapeSequences . Grey ) } ] ` ;
55- output += `${ flattenDiagnosticMessageText ( diagnostic . messageText , system . newLine ) } ${ newLine + newLine + newLine } ` ;
73+ output += `${ flattenDiagnosticMessageText ( diagnostic . messageText , system . newLine ) } ${ newLine + newLine } ` ;
5674 system . write ( output ) ;
5775 } :
5876 ( diagnostic , newLine , options ) => {
5977 clearScreenIfNotWatchingForFileChanges ( system , diagnostic , options ) ;
60- let output = new Date ( ) . toLocaleTimeString ( ) + " - " ;
61- output += `${ flattenDiagnosticMessageText ( diagnostic . messageText , system . newLine ) } ${ newLine + newLine + newLine } ` ;
78+ let output = ` ${ getPlainDiagnosticPrecedingNewLines ( diagnostic , newLine ) } ${ new Date ( ) . toLocaleTimeString ( ) } - ` ;
79+ output += `${ flattenDiagnosticMessageText ( diagnostic . messageText , system . newLine ) } ${ getPlainDiagnosticFollowingNewLines ( diagnostic , newLine ) } ` ;
6280 system . write ( output ) ;
6381 } ;
6482 }
0 commit comments