Skip to content

Commit 070218f

Browse files
author
Andy
authored
Remove DirectoryOfFailedLookupWatch#ignore, use DirectoryOfFailedLookupWatch | undefined (microsoft#28091)
1 parent efc831e commit 070218f

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

src/compiler/resolutionCache.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ namespace ts {
6969
dir: string;
7070
dirPath: Path;
7171
nonRecursive?: boolean;
72-
ignore?: true;
7372
}
7473

7574
export const maxNumberOfFilesToIterateForInvalidation = 256;
@@ -401,14 +400,7 @@ namespace ts {
401400
return true;
402401
}
403402

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 {
412404
if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
413405
// Ensure failed look up is normalized path
414406
failedLookupLocation = isRootedDiskPath(failedLookupLocation) ? normalizePath(failedLookupLocation) : getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
@@ -430,7 +422,7 @@ namespace ts {
430422
);
431423
}
432424

433-
function getDirectoryToWatchFromFailedLookupLocationDirectory(dir: string, dirPath: Path) {
425+
function getDirectoryToWatchFromFailedLookupLocationDirectory(dir: string, dirPath: Path): DirectoryOfFailedLookupWatch | undefined {
434426
// If directory path contains node module, get the most parent node_modules directory for watching
435427
while (pathContainsNodeModules(dirPath)) {
436428
dir = getDirectoryPath(dir);
@@ -439,7 +431,7 @@ namespace ts {
439431

440432
// If the directory is node_modules use it to watch, always watch it recursively
441433
if (isNodeModulesDirectory(dirPath)) {
442-
return filterFSRootDirectoriesToWatch({ dir, dirPath }, getDirectoryPath(dirPath));
434+
return canWatchDirectory(getDirectoryPath(dirPath)) ? { dir, dirPath } : undefined;
443435
}
444436

445437
let nonRecursive = true;
@@ -459,7 +451,7 @@ namespace ts {
459451
}
460452
}
461453

462-
return filterFSRootDirectoriesToWatch({ dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive }, dirPath);
454+
return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive } : undefined;
463455
}
464456

465457
function isPathWithDefaultFailedLookupExtension(path: Path) {
@@ -491,8 +483,9 @@ namespace ts {
491483
let setAtRoot = false;
492484
for (const failedLookupLocation of failedLookupLocations) {
493485
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;
496489
// If the failed lookup location path is not one of the supported extensions,
497490
// store it in the custom path
498491
if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
@@ -551,8 +544,9 @@ namespace ts {
551544
let removeAtRoot = false;
552545
for (const failedLookupLocation of failedLookupLocations) {
553546
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;
556550
const refCount = customFailedLookupPaths.get(failedLookupLocationPath);
557551
if (refCount) {
558552
if (refCount === 1) {
@@ -738,8 +732,8 @@ namespace ts {
738732
if (isInDirectoryPath(rootPath, typeRootPath)) {
739733
return rootPath;
740734
}
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;
743737
}
744738

745739
function createTypeRootsWatch(typeRootPath: Path, typeRoot: string): FileWatcher {

0 commit comments

Comments
 (0)