mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-26 19:25:41 -05:00
Reflect getCurrentProgram as Program|undefined in the ResolutionHostCache
If there were any exceptions, the getCurrentProgram might return undefined so this is defensive check for program Fixes #25765
This commit is contained in:
committed by
Mine Starks
parent
d222c95e3a
commit
07da12167e
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user