Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit e0addb0

Browse files
committed
fix: clean up ensureBasicFiles logic
1 parent ed8052b commit e0addb0

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/project-manager.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ export class ProjectConfiguration {
735735
private expectedFilePaths = new Set<string>();
736736

737737
/**
738-
* List of resolved extra root directories to allow global typings to be loaded from.
738+
* List of resolved extra root directories to allow global type declaration files to be loaded from.
739739
*/
740740
private typeRoots: string[];
741741

@@ -873,15 +873,17 @@ export class ProjectConfiguration {
873873

874874
private ensuredBasicFiles = false;
875875

876-
private isTypeRootDeclaration(path: string) {
877-
if (isDeclarationFile(path)) {
878-
for (const base of this.typeRoots) {
879-
if (path.startsWith(base)) {
880-
return true;
881-
}
882-
}
876+
/**
877+
* [isExpectedDeclarationFile description]
878+
* @param {string} fileName [description]
879+
*/
880+
private isExpectedDeclarationFile(fileName: string) {
881+
if (isDeclarationFile(fileName)) {
882+
return this.expectedFilePaths.has(toUnixPath(fileName)) ||
883+
this.typeRoots.some(root => fileName.startsWith(root))
884+
} else {
885+
return false;
883886
}
884-
return false;
885887
}
886888

887889
/**
@@ -903,8 +905,7 @@ export class ProjectConfiguration {
903905
for (const uri of this.fs.uris()) {
904906
const fileName = uri2path(uri);
905907
if (isGlobalTSFile(fileName) ||
906-
this.isTypeRootDeclaration(fileName) ||
907-
(isDeclarationFile(fileName) && this.expectedFilePaths.has(toUnixPath(fileName)))) {
908+
this.isExpectedDeclarationFile(fileName)) {
908909
const sourceFile = program.getSourceFile(fileName);
909910
if (!sourceFile) {
910911
this.getHost().addFile(fileName);

0 commit comments

Comments
 (0)