Merge pull request #25835 from Microsoft/getCurrentProgramOrUndefined

Reflect getCurrentProgram as Program|undefined in the ResolutionHostCache
This commit is contained in:
Sheetal Nandi
2018-07-27 23:06:34 -07:00
committed by GitHub
+3 -2
View File
@@ -52,7 +52,7 @@ namespace ts {
getGlobalCache?(): string | undefined;
writeLog(s: string): void;
maxNumberOfFilesToIterateForInvalidation?: number;
getCurrentProgram(): Program;
getCurrentProgram(): Program | undefined;
}
interface DirectoryWatchesOfFailedLookup {
@@ -497,7 +497,8 @@ namespace ts {
}
function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions: ResolutionWithFailedLookupLocations[], name: string) {
const updateResolution = resolutionHost.getCurrentProgram().getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name) ?
const program = resolutionHost.getCurrentProgram();
const updateResolution = program && program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name) ?
setRefCountToUndefined : watchFailedLookupLocationOfResolution;
resolutions.forEach(updateResolution);
}