@@ -90,12 +90,17 @@ watchMain();
90
90
* Please log a "breaking change" issue for any API breaking change affecting this issue
91
91
*/
92
92
exports . __esModule = true ;
93
+
93
94
var ts = require ( "typescript" ) ;
95
+
94
96
var formatHost = {
95
97
getCanonicalFileName : function ( path ) { return path ; } ,
96
98
getCurrentDirectory : ts . sys . getCurrentDirectory ,
97
99
getNewLine : function ( ) { return ts . sys . newLine ; }
98
- } ;
100
+ }
101
+
102
+ ;
103
+
99
104
function watchMain ( ) {
100
105
var configPath = ts . findConfigFile ( /*searchPath*/ "./" , ts . sys . fileExists , "tsconfig.json" ) ;
101
106
if ( ! configPath ) {
@@ -111,7 +116,11 @@ function watchMain() {
111
116
// Between `createEmitAndSemanticDiagnosticsBuilderProgram` and `createSemanticDiagnosticsBuilderProgram`, the only difference is emit.
112
117
// For pure type-checking scenarios, or when another tool/process handles emit, using `createSemanticDiagnosticsBuilderProgram` may be more desirable.
113
118
// 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
+
115
124
// You can technically override any given hook on the host, though you probably don't need to.
116
125
// Note that we're assuming `origCreateProgram` and `origPostProgramCreate` doesn't use `this` at all.
117
126
var origCreateProgram = host . createProgram ;
@@ -120,16 +129,21 @@ function watchMain() {
120
129
return origCreateProgram ( rootNames , options , host , oldProgram ) ;
121
130
} ;
122
131
var origPostProgramCreate = host . afterProgramCreate ;
132
+
123
133
host . afterProgramCreate = function ( program ) {
124
134
console . log ( "** We finished making the program! **" ) ;
125
135
origPostProgramCreate ( program ) ;
126
136
} ;
127
137
// `createWatchProgram` creates an initial program, watches files, and updates the program over time.
128
138
ts . createWatchProgram ( host ) ;
129
139
}
140
+
130
141
function 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
+ ) ;
132
145
}
146
+
133
147
/**
134
148
* Prints a diagnostic every time the watch status changes.
135
149
* This is mainly for messages like "Starting compilation" or "Compilation completed".
0 commit comments