diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index a12554addfe6f..64ef1b552f5fa 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -212,6 +212,11 @@ namespace Harness.LanguageService { return script ? script.version.toString() : undefined; } + directoryExists(dirName: string): boolean { + const fileEntry = this.virtualFileSystem.traversePath(dirName); + return fileEntry && fileEntry.isDirectory(); + } + fileExists(fileName: string): boolean { const script = this.getScriptSnapshot(fileName); return script !== undefined; diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 3e4e0f9e82246..1167f117c330e 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -367,7 +367,8 @@ namespace ts.codefix { getCanonicalFileName: (file: string) => string, moduleFileName: string, ): string | undefined { - return firstDefined(getEffectiveTypeRoots(options, host), unNormalizedTypeRoot => { + const roots = getEffectiveTypeRoots(options, host); + return roots && firstDefined(roots, unNormalizedTypeRoot => { const typeRoot = toPath(unNormalizedTypeRoot, /*basePath*/ undefined, getCanonicalFileName); if (startsWith(moduleFileName, typeRoot)) { return removeExtensionAndIndexPostFix(moduleFileName.substring(typeRoot.length + 1));