@@ -69,7 +69,6 @@ namespace ts {
69
69
dir : string ;
70
70
dirPath : Path ;
71
71
nonRecursive ?: boolean ;
72
- ignore ?: true ;
73
72
}
74
73
75
74
export const maxNumberOfFilesToIterateForInvalidation = 256 ;
@@ -401,14 +400,7 @@ namespace ts {
401
400
return true ;
402
401
}
403
402
404
- function filterFSRootDirectoriesToWatch ( watchPath : DirectoryOfFailedLookupWatch , dirPath : Path ) : DirectoryOfFailedLookupWatch {
405
- if ( ! canWatchDirectory ( dirPath ) ) {
406
- watchPath . ignore = true ;
407
- }
408
- return watchPath ;
409
- }
410
-
411
- function getDirectoryToWatchFailedLookupLocation ( failedLookupLocation : string , failedLookupLocationPath : Path ) : DirectoryOfFailedLookupWatch {
403
+ function getDirectoryToWatchFailedLookupLocation ( failedLookupLocation : string , failedLookupLocationPath : Path ) : DirectoryOfFailedLookupWatch | undefined {
412
404
if ( isInDirectoryPath ( rootPath , failedLookupLocationPath ) ) {
413
405
// Ensure failed look up is normalized path
414
406
failedLookupLocation = isRootedDiskPath ( failedLookupLocation ) ? normalizePath ( failedLookupLocation ) : getNormalizedAbsolutePath ( failedLookupLocation , getCurrentDirectory ( ) ) ;
@@ -430,7 +422,7 @@ namespace ts {
430
422
) ;
431
423
}
432
424
433
- function getDirectoryToWatchFromFailedLookupLocationDirectory ( dir : string , dirPath : Path ) {
425
+ function getDirectoryToWatchFromFailedLookupLocationDirectory ( dir : string , dirPath : Path ) : DirectoryOfFailedLookupWatch | undefined {
434
426
// If directory path contains node module, get the most parent node_modules directory for watching
435
427
while ( pathContainsNodeModules ( dirPath ) ) {
436
428
dir = getDirectoryPath ( dir ) ;
@@ -439,7 +431,7 @@ namespace ts {
439
431
440
432
// If the directory is node_modules use it to watch, always watch it recursively
441
433
if ( isNodeModulesDirectory ( dirPath ) ) {
442
- return filterFSRootDirectoriesToWatch ( { dir, dirPath } , getDirectoryPath ( dirPath ) ) ;
434
+ return canWatchDirectory ( getDirectoryPath ( dirPath ) ) ? { dir, dirPath } : undefined ;
443
435
}
444
436
445
437
let nonRecursive = true ;
@@ -459,7 +451,7 @@ namespace ts {
459
451
}
460
452
}
461
453
462
- return filterFSRootDirectoriesToWatch ( { dir : subDirectory || dir , dirPath : subDirectoryPath || dirPath , nonRecursive } , dirPath ) ;
454
+ return canWatchDirectory ( dirPath ) ? { dir : subDirectory || dir , dirPath : subDirectoryPath || dirPath , nonRecursive } : undefined ;
463
455
}
464
456
465
457
function isPathWithDefaultFailedLookupExtension ( path : Path ) {
@@ -491,8 +483,9 @@ namespace ts {
491
483
let setAtRoot = false ;
492
484
for ( const failedLookupLocation of failedLookupLocations ) {
493
485
const failedLookupLocationPath = resolutionHost . toPath ( failedLookupLocation ) ;
494
- const { dir, dirPath, nonRecursive, ignore } = getDirectoryToWatchFailedLookupLocation ( failedLookupLocation , failedLookupLocationPath ) ;
495
- if ( ! ignore ) {
486
+ const toWatch = getDirectoryToWatchFailedLookupLocation ( failedLookupLocation , failedLookupLocationPath ) ;
487
+ if ( toWatch ) {
488
+ const { dir, dirPath, nonRecursive } = toWatch ;
496
489
// If the failed lookup location path is not one of the supported extensions,
497
490
// store it in the custom path
498
491
if ( ! isPathWithDefaultFailedLookupExtension ( failedLookupLocationPath ) ) {
@@ -551,8 +544,9 @@ namespace ts {
551
544
let removeAtRoot = false ;
552
545
for ( const failedLookupLocation of failedLookupLocations ) {
553
546
const failedLookupLocationPath = resolutionHost . toPath ( failedLookupLocation ) ;
554
- const { dirPath, ignore } = getDirectoryToWatchFailedLookupLocation ( failedLookupLocation , failedLookupLocationPath ) ;
555
- if ( ! ignore ) {
547
+ const toWatch = getDirectoryToWatchFailedLookupLocation ( failedLookupLocation , failedLookupLocationPath ) ;
548
+ if ( toWatch ) {
549
+ const { dirPath } = toWatch ;
556
550
const refCount = customFailedLookupPaths . get ( failedLookupLocationPath ) ;
557
551
if ( refCount ) {
558
552
if ( refCount === 1 ) {
@@ -738,8 +732,8 @@ namespace ts {
738
732
if ( isInDirectoryPath ( rootPath , typeRootPath ) ) {
739
733
return rootPath ;
740
734
}
741
- const { dirPath , ignore } = getDirectoryToWatchFromFailedLookupLocationDirectory ( typeRoot , typeRootPath ) ;
742
- return ! ignore && directoryWatchesOfFailedLookups . has ( dirPath ) ? dirPath : undefined ;
735
+ const toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory ( typeRoot , typeRootPath ) ;
736
+ return toWatch && directoryWatchesOfFailedLookups . has ( toWatch . dirPath ) ? toWatch . dirPath : undefined ;
743
737
}
744
738
745
739
function createTypeRootsWatch ( typeRootPath : Path , typeRoot : string ) : FileWatcher {
0 commit comments