Skip to content

Commit 14c860b

Browse files
amcaseymhegazy
authored andcommitted
Don't get typings for projects with disabled language services (#18324)
1 parent cab65ba commit 14c860b

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

src/server/project.ts

+20-21
Original file line numberDiff line numberDiff line change
@@ -543,33 +543,32 @@ namespace ts.server {
543543
this.cachedUnresolvedImportsPerFile.remove(file);
544544
}
545545

546-
// 1. no changes in structure, no changes in unresolved imports - do nothing
547-
// 2. no changes in structure, unresolved imports were changed - collect unresolved imports for all files
548-
// (can reuse cached imports for files that were not changed)
549-
// 3. new files were added/removed, but compilation settings stays the same - collect unresolved imports for all new/modified files
550-
// (can reuse cached imports for files that were not changed)
551-
// 4. compilation settings were changed in the way that might affect module resolution - drop all caches and collect all data from the scratch
552-
let unresolvedImports: SortedReadonlyArray<string>;
553-
if (hasChanges || changedFiles.length) {
554-
const result: string[] = [];
555-
for (const sourceFile of this.program.getSourceFiles()) {
556-
this.extractUnresolvedImportsFromSourceFile(sourceFile, result);
557-
}
558-
this.lastCachedUnresolvedImportsList = toDeduplicatedSortedArray(result);
559-
}
560-
unresolvedImports = this.lastCachedUnresolvedImportsList;
561-
562-
const cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, unresolvedImports, hasChanges);
563-
if (this.setTypings(cachedTypings)) {
564-
hasChanges = this.updateGraphWorker() || hasChanges;
565-
}
566-
567546
// update builder only if language service is enabled
568547
// otherwise tell it to drop its internal state
569548
if (this.languageServiceEnabled) {
549+
// 1. no changes in structure, no changes in unresolved imports - do nothing
550+
// 2. no changes in structure, unresolved imports were changed - collect unresolved imports for all files
551+
// (can reuse cached imports for files that were not changed)
552+
// 3. new files were added/removed, but compilation settings stays the same - collect unresolved imports for all new/modified files
553+
// (can reuse cached imports for files that were not changed)
554+
// 4. compilation settings were changed in the way that might affect module resolution - drop all caches and collect all data from the scratch
555+
if (hasChanges || changedFiles.length) {
556+
const result: string[] = [];
557+
for (const sourceFile of this.program.getSourceFiles()) {
558+
this.extractUnresolvedImportsFromSourceFile(sourceFile, result);
559+
}
560+
this.lastCachedUnresolvedImportsList = toDeduplicatedSortedArray(result);
561+
}
562+
563+
const cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, this.lastCachedUnresolvedImportsList, hasChanges);
564+
if (this.setTypings(cachedTypings)) {
565+
hasChanges = this.updateGraphWorker() || hasChanges;
566+
}
567+
570568
this.builder.onProjectUpdateGraph();
571569
}
572570
else {
571+
this.lastCachedUnresolvedImportsList = undefined;
573572
this.builder.clear();
574573
}
575574

0 commit comments

Comments
 (0)