Skip to content

Commit a26aff3

Browse files
authored
Merge pull request microsoft#25835 from Microsoft/getCurrentProgramOrUndefined
Reflect getCurrentProgram as Program|undefined in the ResolutionHostCache
2 parents 5e1872f + b31f242 commit a26aff3

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)