@@ -212,8 +212,8 @@ namespace ts {
212212 }
213213
214214 export interface Watch {
215- /** Synchronize the program with the changes */
216- synchronizeProgram ( ) : void ;
215+ /** Synchronize with host and get updated program */
216+ getProgram ( ) : Program ;
217217 /** Gets the existing program without synchronizing with changes on host */
218218 /*@internal */
219219 getExistingProgram ( ) : Program ;
@@ -360,10 +360,10 @@ namespace ts {
360360 watchConfigFileWildCardDirectories ( ) ;
361361
362362 return configFileName ?
363- { getExistingProgram : ( ) => program , synchronizeProgram } :
364- { getExistingProgram : ( ) => program , synchronizeProgram, updateRootFileNames } ;
363+ { getExistingProgram : ( ) => program , getProgram : synchronizeProgram } :
364+ { getExistingProgram : ( ) => program , getProgram : synchronizeProgram , updateRootFileNames } ;
365365
366- function synchronizeProgram ( ) {
366+ function synchronizeProgram ( ) : Program {
367367 writeLog ( `Synchronizing program` ) ;
368368
369369 if ( hasChangedCompilerOptions ) {
@@ -375,7 +375,7 @@ namespace ts {
375375
376376 const hasInvalidatedResolution = resolutionCache . createHasInvalidatedResolution ( ) ;
377377 if ( isProgramUptoDate ( program , rootFileNames , compilerOptions , getSourceVersion , fileExists , hasInvalidatedResolution , hasChangedAutomaticTypeDirectiveNames ) ) {
378- return ;
378+ return program ;
379379 }
380380
381381 beforeProgramCreate ( compilerOptions ) ;
@@ -411,6 +411,7 @@ namespace ts {
411411
412412 afterProgramCreate ( directoryStructureHost , program ) ;
413413 reportWatchDiagnostic ( createCompilerDiagnostic ( Diagnostics . Compilation_complete_Watching_for_file_changes ) ) ;
414+ return program ;
414415 }
415416
416417 function updateRootFileNames ( files : string [ ] ) {
@@ -569,7 +570,8 @@ namespace ts {
569570 case ConfigFileProgramReloadLevel . Full :
570571 return reloadConfigFile ( ) ;
571572 default :
572- return synchronizeProgram ( ) ;
573+ synchronizeProgram ( ) ;
574+ return ;
573575 }
574576 }
575577
0 commit comments