@@ -86,7 +86,6 @@ namespace ts {
8686
8787 if ( diagnostic . file ) {
8888 let loc = getLineAndCharacterOfPosition ( diagnostic . file , diagnostic . start ) ;
89-
9089 output += `${ diagnostic . file . fileName } (${ loc . line + 1 } ,${ loc . character + 1 } ): ` ;
9190 }
9291
@@ -102,6 +101,19 @@ namespace ts {
102101 }
103102 }
104103
104+ function reportWatchDiagnostic ( diagnostic : Diagnostic ) {
105+ let output = new Date ( ) . toLocaleTimeString ( ) + " - " ;
106+
107+ if ( diagnostic . file ) {
108+ let loc = getLineAndCharacterOfPosition ( diagnostic . file , diagnostic . start ) ;
109+ output += `${ diagnostic . file . fileName } (${ loc . line + 1 } ,${ loc . character + 1 } ): ` ;
110+ }
111+
112+ output += `${ flattenDiagnosticMessageText ( diagnostic . messageText , sys . newLine ) } ${ sys . newLine } ` ;
113+
114+ sys . write ( output ) ;
115+ }
116+
105117 function padLeft ( s : string , length : number ) {
106118 while ( s . length < length ) {
107119 s = " " + s ;
@@ -218,7 +230,7 @@ namespace ts {
218230
219231 let result = readConfigFile ( configFileName , sys . readFile ) ;
220232 if ( result . error ) {
221- reportDiagnostic ( result . error ) ;
233+ reportWatchDiagnostic ( result . error ) ;
222234 return sys . exit ( ExitStatus . DiagnosticsPresent_OutputsSkipped ) ;
223235 }
224236
@@ -247,7 +259,7 @@ namespace ts {
247259 }
248260
249261 setCachedProgram ( compileResult . program ) ;
250- reportDiagnostic ( createCompilerDiagnostic ( Diagnostics . Compilation_complete_Watching_for_file_changes ) ) ;
262+ reportWatchDiagnostic ( createCompilerDiagnostic ( Diagnostics . Compilation_complete_Watching_for_file_changes ) ) ;
251263 }
252264
253265 function getSourceFile ( fileName : string , languageVersion : ScriptTarget , onError ?: ( message : string ) => void ) {
@@ -309,7 +321,7 @@ namespace ts {
309321
310322 function recompile ( ) {
311323 timerHandle = undefined ;
312- reportDiagnostic ( createCompilerDiagnostic ( Diagnostics . File_change_detected_Starting_incremental_compilation ) ) ;
324+ reportWatchDiagnostic ( createCompilerDiagnostic ( Diagnostics . File_change_detected_Starting_incremental_compilation ) ) ;
313325 performCompilation ( ) ;
314326 }
315327 }
0 commit comments