Skip to content

Commit d5cad23

Browse files
committed
Add nullchecks for typeRoots, remove getCurrentDirectory from ServerHost as it is always the installation location
1 parent 6ff91b8 commit d5cad23

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/compiler/program.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ namespace ts {
242242
const failedLookupLocations: string[] = [];
243243

244244
// Check primary library paths
245-
if (typeRoots.length) {
245+
if (typeRoots && typeRoots.length) {
246246
if (traceEnabled) {
247247
trace(host, Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", "));
248248
}
@@ -1060,9 +1060,11 @@ namespace ts {
10601060
let result: string[] = [];
10611061
if (host.directoryExists && host.getDirectories) {
10621062
const typeRoots = getEffectiveTypeRoots(options, host);
1063-
for (const root of typeRoots) {
1064-
if (host.directoryExists(root)) {
1065-
result = result.concat(host.getDirectories(root));
1063+
if (typeRoots) {
1064+
for (const root of typeRoots) {
1065+
if (host.directoryExists(root)) {
1066+
result = result.concat(host.getDirectories(root));
1067+
}
10661068
}
10671069
}
10681070
}

src/server/editorServices.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ namespace ts.server {
113113
this.moduleResolutionHost = {
114114
fileExists: fileName => this.fileExists(fileName),
115115
readFile: fileName => this.host.readFile(fileName),
116-
getCurrentDirectory: () => this.host.getCurrentDirectory(),
117116
directoryExists: directoryName => this.host.directoryExists(directoryName)
118117
};
119118
}

0 commit comments

Comments
 (0)