@@ -364,7 +364,8 @@ namespace ts.server {
364364 }
365365
366366 private onTypeRootFileChanged ( project : ConfiguredProject , fileName : string ) {
367- this . onSourceFileInDirectoryChangedForConfiguredProject ( project , fileName ) ;
367+ this . updateConfiguredProject ( project ) ;
368+ this . refreshInferredProjects ( ) ;
368369 }
369370
370371 /**
@@ -387,18 +388,27 @@ namespace ts.server {
387388 ( ) => this . handleChangeInSourceFileForConfiguredProject ( project ) ) ;
388389 }
389390
390- private handleChangeInSourceFileForConfiguredProject ( project : ConfiguredProject ) {
391- const { projectOptions, configFileErrors } = this . convertConfigFileContentToProjectOptions ( project . configFileName ) ;
392- this . reportConfigFileDiagnostics ( project . getProjectName ( ) , configFileErrors ) ;
391+ getTypeRootsVersion ( project : ConfiguredProject ) {
392+ const roots = project . getEffectiveTypeRoots ( ) ;
393+ if ( roots === undefined ) {
394+ return 0 ;
395+ }
393396
394- const newRootFiles = projectOptions . files . map ( ( f => this . getCanonicalFileName ( f ) ) ) ;
395- const currentRootFiles = project . getRootFiles ( ) . map ( ( f => this . getCanonicalFileName ( f ) ) ) ;
396- const lastUpdateTypesRoot : number = Math . max . apply ( Math , project . getEffectiveTypeRoots ( ) . map ( root => {
397+ return Math . max . apply ( Math , project . getEffectiveTypeRoots ( ) . map ( root => {
397398 if ( this . host . directoryExists ( root ) ) {
398399 return + this . host . getModifiedTime ( root ) ;
399400 }
400401 return 0 ;
401402 } ) ) ;
403+ }
404+
405+ private handleChangeInSourceFileForConfiguredProject ( project : ConfiguredProject ) {
406+ const { projectOptions, configFileErrors } = this . convertConfigFileContentToProjectOptions ( project . configFileName ) ;
407+ this . reportConfigFileDiagnostics ( project . getProjectName ( ) , configFileErrors ) ;
408+
409+ const newRootFiles = projectOptions . files . map ( ( f => this . getCanonicalFileName ( f ) ) ) ;
410+ const currentRootFiles = project . getRootFiles ( ) . map ( ( f => this . getCanonicalFileName ( f ) ) ) ;
411+ const lastUpdateTypesRoot : number = this . getTypeRootsVersion ( project ) ;
402412
403413 // We check if the project file list has changed. If so, we update the project.
404414 if ( ! arrayIsEqualTo ( currentRootFiles . sort ( ) , newRootFiles . sort ( ) ) || ( lastUpdateTypesRoot > project . lastUpdatedTypesRootTime ) ) {
0 commit comments