Skip to content

Commit b31f242

Browse files
committed
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
1 parent bcd5652 commit b31f242

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/compiler/resolutionCache.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace ts {
5252
getGlobalCache?(): string | undefined;
5353
writeLog(s: string): void;
5454
maxNumberOfFilesToIterateForInvalidation?: number;
55-
getCurrentProgram(): Program;
55+
getCurrentProgram(): Program | undefined;
5656
}
5757

5858
interface DirectoryWatchesOfFailedLookup {
@@ -497,7 +497,8 @@ namespace ts {
497497
}
498498

499499
function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions: ResolutionWithFailedLookupLocations[], name: string) {
500-
const updateResolution = resolutionHost.getCurrentProgram().getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name) ?
500+
const program = resolutionHost.getCurrentProgram();
501+
const updateResolution = program && program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name) ?
501502
setRefCountToUndefined : watchFailedLookupLocationOfResolution;
502503
resolutions.forEach(updateResolution);
503504
}

0 commit comments

Comments
 (0)