@@ -90,12 +90,17 @@ watchMain();
9090 * Please log a "breaking change" issue for any API breaking change affecting this issue
9191 */
9292exports . __esModule = true ;
93+
9394var ts = require ( "typescript" ) ;
95+
9496var formatHost = {
9597 getCanonicalFileName : function ( path ) { return path ; } ,
9698 getCurrentDirectory : ts . sys . getCurrentDirectory ,
9799 getNewLine : function ( ) { return ts . sys . newLine ; }
98- } ;
100+ }
101+
102+ ;
103+
99104function watchMain ( ) {
100105 var configPath = ts . findConfigFile ( /*searchPath*/ "./" , ts . sys . fileExists , "tsconfig.json" ) ;
101106 if ( ! configPath ) {
@@ -111,7 +116,11 @@ function watchMain() {
111116 // Between `createEmitAndSemanticDiagnosticsBuilderProgram` and `createSemanticDiagnosticsBuilderProgram`, the only difference is emit.
112117 // For pure type-checking scenarios, or when another tool/process handles emit, using `createSemanticDiagnosticsBuilderProgram` may be more desirable.
113118 // Note that there is another overload for `createWatchCompilerHost` that takes a set of root files.
114- var host = ts . createWatchCompilerHost ( configPath , { } , ts . sys , ts . createSemanticDiagnosticsBuilderProgram , reportDiagnostic , reportWatchStatusChanged ) ;
119+ var host = ts . createWatchCompilerHost ( configPath , { } , ts . sys ,
120+ ts . createSemanticDiagnosticsBuilderProgram ,
121+ reportDiagnostic ,
122+ reportWatchStatusChanged ) ;
123+
115124 // You can technically override any given hook on the host, though you probably don't need to.
116125 // Note that we're assuming `origCreateProgram` and `origPostProgramCreate` doesn't use `this` at all.
117126 var origCreateProgram = host . createProgram ;
@@ -120,16 +129,21 @@ function watchMain() {
120129 return origCreateProgram ( rootNames , options , host , oldProgram ) ;
121130 } ;
122131 var origPostProgramCreate = host . afterProgramCreate ;
132+
123133 host . afterProgramCreate = function ( program ) {
124134 console . log ( "** We finished making the program! **" ) ;
125135 origPostProgramCreate ( program ) ;
126136 } ;
127137 // `createWatchProgram` creates an initial program, watches files, and updates the program over time.
128138 ts . createWatchProgram ( host ) ;
129139}
140+
130141function reportDiagnostic ( diagnostic ) {
131- console . error ( "Error" , diagnostic . code , ":" , ts . flattenDiagnosticMessageText ( diagnostic . messageText , formatHost . getNewLine ( ) ) ) ;
142+ console . error ( "Error" , diagnostic . code , ":" ,
143+ ts . flattenDiagnosticMessageText ( diagnostic . messageText , formatHost . getNewLine ( ) )
144+ ) ;
132145}
146+
133147/**
134148 * Prints a diagnostic every time the watch status changes.
135149 * This is mainly for messages like "Starting compilation" or "Compilation completed".
0 commit comments