Skip to content

Commit

Permalink
Merge pull request #19088 from Microsoft/resolutionCacheDefensiveChecks
Browse files Browse the repository at this point in the history
Function to clear the per directory resolution
  • Loading branch information
sheetalkamat authored Oct 12, 2017
2 parents 728d2a9 + cb326ed commit 5a776e2
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/compiler/resolutionCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ namespace ts {
return {
startRecordingFilesWithChangedResolutions,
finishRecordingFilesWithChangedResolutions,
startCachingPerDirectoryResolution,
// perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
// (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
startCachingPerDirectoryResolution: clearPerDirectoryResolutions,
finishCachingPerDirectoryResolution,
resolveModuleNames,
resolveTypeReferenceDirectives,
Expand Down Expand Up @@ -143,8 +145,7 @@ namespace ts {
allFilesHaveInvalidatedResolution = false;
// perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
// (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
perDirectoryResolvedModuleNames.clear();
perDirectoryResolvedTypeReferenceDirectives.clear();
clearPerDirectoryResolutions();
}

function startRecordingFilesWithChangedResolutions() {
Expand All @@ -168,9 +169,7 @@ namespace ts {
return path => collected && collected.has(path);
}

function startCachingPerDirectoryResolution() {
// perDirectoryResolvedModuleNames and perDirectoryResolvedTypeReferenceDirectives could be non empty if there was exception during program update
// (between startCachingPerDirectoryResolution and finishCachingPerDirectoryResolution)
function clearPerDirectoryResolutions() {
perDirectoryResolvedModuleNames.clear();
perDirectoryResolvedTypeReferenceDirectives.clear();
}
Expand All @@ -184,8 +183,7 @@ namespace ts {
}
});

perDirectoryResolvedModuleNames.clear();
perDirectoryResolvedTypeReferenceDirectives.clear();
clearPerDirectoryResolutions();
}

function resolveModuleName(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost): ResolvedModuleWithFailedLookupLocations {
Expand Down

0 comments on commit 5a776e2

Please sign in to comment.