@@ -165,10 +165,10 @@ namespace ts {
165165 /** FS system to use */
166166 system : System ;
167167
168- /** Custom action before creating the program */
169- beforeProgramCreate ( compilerOptions : CompilerOptions ) : void ;
170- /** Custom action after new program creation is successful */
171- afterProgramCreate ( host : DirectoryStructureHost , program : Program ) : void ;
168+ /** If provided, callback to invoke before each program creation */
169+ beforeProgramCreate ? ( compilerOptions : CompilerOptions ) : void ;
170+ /** If provided, callback to invoke after every new program creation */
171+ afterProgramCreate ? ( host : DirectoryStructureHost , program : Program ) : void ;
172172
173173 /** Optional module name resolver */
174174 resolveModuleNames ?( moduleNames : string [ ] , containingFile : string , reusedNames ?: string [ ] ) : ResolvedModule [ ] ;
@@ -239,7 +239,6 @@ namespace ts {
239239 export function createWatchOfConfigFile ( configFileName : string , optionsToExtend ?: CompilerOptions , system = sys , reportDiagnostic ?: DiagnosticReporter ) : WatchOfConfigFile {
240240 return createWatch ( {
241241 system,
242- beforeProgramCreate : noop ,
243242 afterProgramCreate : createProgramCompilerWithBuilderState ( system , reportDiagnostic ) ,
244243 onConfigFileDiagnostic : reportDiagnostic || createDiagnosticReporter ( system ) ,
245244 configFileName,
@@ -253,7 +252,6 @@ namespace ts {
253252 export function createWatchOfFilesAndCompilerOptions ( rootFiles : string [ ] , options : CompilerOptions , system = sys , reportDiagnostic ?: DiagnosticReporter ) : WatchOfFilesAndCompilerOptions {
254253 return createWatch ( {
255254 system,
256- beforeProgramCreate : noop ,
257255 afterProgramCreate : createProgramCompilerWithBuilderState ( system , reportDiagnostic ) ,
258256 rootFiles,
259257 options
@@ -286,7 +284,9 @@ namespace ts {
286284 let hasChangedCompilerOptions = false ; // True if the compiler options have changed between compilations
287285 let hasChangedAutomaticTypeDirectiveNames = false ; // True if the automatic type directives have changed
288286
289- const { system, configFileName, onConfigFileDiagnostic, afterProgramCreate, beforeProgramCreate, optionsToExtend : optionsToExtendForConfigFile = { } } = host as WatchOfConfigFileHost ;
287+ const { system, configFileName, onConfigFileDiagnostic, optionsToExtend : optionsToExtendForConfigFile = { } } = host as WatchOfConfigFileHost ;
288+ const beforeProgramCreate : WatchHost [ "beforeProgramCreate" ] = host . beforeProgramCreate ? host . beforeProgramCreate . bind ( host ) : noop ;
289+ const afterProgramCreate : WatchHost [ "afterProgramCreate" ] = host . afterProgramCreate ? host . afterProgramCreate . bind ( host ) : noop ;
290290 let { rootFiles : rootFileNames , options : compilerOptions , configFileSpecs, configFileWildCardDirectories } = host as WatchOfConfigFileHost ;
291291
292292 // From tsc we want to get already parsed result and hence check for rootFileNames
0 commit comments