@@ -3775,24 +3775,26 @@ namespace ts.server {
3775
3775
getPackageJsonsVisibleToFile ( fileName : string , rootDir ?: string ) : readonly PackageJsonInfo [ ] {
3776
3776
const packageJsonCache = this . packageJsonCache ;
3777
3777
const watchPackageJsonFile = this . watchPackageJsonFile . bind ( this ) ;
3778
- const toPath = this . toPath . bind ( this ) ;
3779
- const rootPath = rootDir && toPath ( rootDir ) ;
3780
- const filePath = toPath ( fileName ) ;
3778
+ const rootPath = rootDir && this . toPath ( rootDir ) ;
3779
+ const filePath = this . toPath ( fileName ) ;
3781
3780
const result : PackageJsonInfo [ ] = [ ] ;
3782
- forEachAncestorDirectory ( getDirectoryPath ( filePath ) , function processDirectory ( directory ) : boolean | undefined {
3781
+ forEachAncestorDirectory ( getDirectoryPath ( filePath ) , directory => {
3783
3782
switch ( packageJsonCache . directoryHasPackageJson ( directory ) ) {
3784
3783
// Sync and check same directory again
3785
3784
case Ternary . Maybe :
3786
3785
packageJsonCache . searchDirectoryAndAncestors ( directory ) ;
3787
- return processDirectory ( directory ) ;
3788
- // Check package.json
3786
+ if ( packageJsonCache . directoryHasPackageJson ( directory ) !== Ternary . True ) {
3787
+ return false ;
3788
+ }
3789
+ // fall through
3790
+ // Check the package.json
3789
3791
case Ternary . True :
3790
3792
const packageJsonFileName = combinePaths ( directory , "package.json" ) ;
3791
3793
watchPackageJsonFile ( packageJsonFileName ) ;
3792
3794
const info = packageJsonCache . getInDirectory ( directory ) ;
3793
3795
if ( info ) result . push ( info ) ;
3794
3796
}
3795
- if ( rootPath && rootPath === toPath ( directory ) ) {
3797
+ if ( rootPath && rootPath === this . toPath ( directory ) ) {
3796
3798
return true ;
3797
3799
}
3798
3800
} ) ;
0 commit comments