@@ -772,9 +772,9 @@ namespace ts.server {
772
772
773
773
this.rootFiles = undefined!;
774
774
this.rootFilesMap = undefined!;
775
- this.externalFiles = undefined! ;
776
- this.program = undefined! ;
777
- this.builderState = undefined! ;
775
+ this.externalFiles = undefined;
776
+ this.program = undefined;
777
+ this.builderState = undefined;
778
778
this.resolutionCache.clear();
779
779
this.resolutionCache = undefined!;
780
780
this.cachedUnresolvedImportsPerFile = undefined!;
@@ -784,7 +784,7 @@ namespace ts.server {
784
784
// Clean up file watchers waiting for missing files
785
785
if (this.missingFilesMap) {
786
786
clearMap(this.missingFilesMap, closeFileWatcher);
787
- this.missingFilesMap = undefined! ;
787
+ this.missingFilesMap = undefined;
788
788
}
789
789
this.clearGeneratedFileWatch();
790
790
this.clearInvalidateResolutionOfFailedLookupTimer();
@@ -1087,7 +1087,7 @@ namespace ts.server {
1087
1087
const start = timestamp();
1088
1088
this.hasInvalidatedResolution = this.resolutionCache.createHasInvalidatedResolution();
1089
1089
this.resolutionCache.startCachingPerDirectoryResolution();
1090
- this.program = this.languageService.getProgram()! ; // TODO: GH#18217
1090
+ this.program = this.languageService.getProgram(); // TODO: GH#18217
1091
1091
this.dirty = false;
1092
1092
this.resolutionCache.finishCachingPerDirectoryResolution();
1093
1093
@@ -1096,8 +1096,9 @@ namespace ts.server {
1096
1096
// bump up the version if
1097
1097
// - oldProgram is not set - this is a first time updateGraph is called
1098
1098
// - newProgram is different from the old program and structure of the old program was not reused.
1099
- const hasNewProgram = this.program && (!oldProgram || (this.program !== oldProgram && !(this.program.structureIsReused & StructureIsReused.Completely)));
1100
- if (hasNewProgram) {
1099
+ let hasNewProgram = false;
1100
+ if (this.program && (!oldProgram || (this.program !== oldProgram && !(this.program.structureIsReused & StructureIsReused.Completely)))) {
1101
+ hasNewProgram = true;
1101
1102
if (oldProgram) {
1102
1103
for (const f of oldProgram.getSourceFiles()) {
1103
1104
const newFile = this.program.getSourceFileByPath(f.resolvedPath);
@@ -1163,7 +1164,7 @@ namespace ts.server {
1163
1164
}
1164
1165
1165
1166
if (!this.importSuggestionsCache.isEmpty()) {
1166
- if (this.hasAddedorRemovedFiles || oldProgram && !this.program.structureIsReused) {
1167
+ if (this.hasAddedorRemovedFiles || oldProgram && !this.program! .structureIsReused) {
1167
1168
this.importSuggestionsCache.clear();
1168
1169
}
1169
1170
else if (this.dirtyFilesForSuggestions && oldProgram && this.program) {
@@ -1204,7 +1205,7 @@ namespace ts.server {
1204
1205
this.print(/*writeProjectFileNames*/ true);
1205
1206
}
1206
1207
else if (this.program !== oldProgram) {
1207
- this.writeLog(`Different program with same set of files:: structureIsReused:: ${this.program.structureIsReused}`);
1208
+ this.writeLog(`Different program with same set of files:: structureIsReused:: ${this.program? .structureIsReused}`);
1208
1209
}
1209
1210
return hasNewProgram;
1210
1211
}
0 commit comments