Skip to content

Commit 097b094

Browse files
committed
Don't get typings for projects with disabled language services
1 parent 8d1eb29 commit 097b094

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

src/server/project.ts

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -547,33 +547,32 @@ namespace ts.server {
547547
this.cachedUnresolvedImportsPerFile.remove(file);
548548
}
549549

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

0 commit comments

Comments
 (0)