From d5cad239e858ca71e89aa8963a7d875928652a65 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Tue, 28 Jun 2016 12:10:26 -0700 Subject: [PATCH] Add nullchecks for typeRoots, remove getCurrentDirectory from ServerHost as it is always the installation location --- src/compiler/program.ts | 10 ++++++---- src/server/editorServices.ts | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index decbb835a8c..fb74f1dcaab 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -242,7 +242,7 @@ namespace ts { const failedLookupLocations: string[] = []; // Check primary library paths - if (typeRoots.length) { + if (typeRoots && typeRoots.length) { if (traceEnabled) { trace(host, Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", ")); } @@ -1060,9 +1060,11 @@ namespace ts { let result: string[] = []; if (host.directoryExists && host.getDirectories) { const typeRoots = getEffectiveTypeRoots(options, host); - for (const root of typeRoots) { - if (host.directoryExists(root)) { - result = result.concat(host.getDirectories(root)); + if (typeRoots) { + for (const root of typeRoots) { + if (host.directoryExists(root)) { + result = result.concat(host.getDirectories(root)); + } } } } diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index e4b989b0ca7..e48d6192017 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -113,7 +113,6 @@ namespace ts.server { this.moduleResolutionHost = { fileExists: fileName => this.fileExists(fileName), readFile: fileName => this.host.readFile(fileName), - getCurrentDirectory: () => this.host.getCurrentDirectory(), directoryExists: directoryName => this.host.directoryExists(directoryName) }; }