Ensure that we are checking if correct file with resolved path is present in the new program when removing the existing packageJson watching (#57988)

This commit is contained in:
Sheetal Nandi
2024-03-28 12:02:45 -07:00
committed by GitHub
parent 35f4f033eb
commit 12402f2609
6 changed files with 2239 additions and 86 deletions

View File

@@ -750,7 +750,8 @@ export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootD
else impliedFormatPackageJsons.delete(newFile.resolvedPath);
});
impliedFormatPackageJsons.forEach((existing, path) => {
if (!newProgram?.getSourceFileByPath(path)) {
const newFile = newProgram?.getSourceFileByPath(path);
if (!newFile || newFile.resolvedPath !== path) {
existing.forEach(location => fileWatchesOfAffectingLocations.get(location)!.files--);
impliedFormatPackageJsons.delete(path);
}