Skip to content

Commit

Permalink
Fix undefined error using getEffectiveTypeRoots (#19300)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy authored and mhegazy committed Oct 18, 2017
1 parent e5f8287 commit f1abe3c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/harness/harnessLanguageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/services/codefixes/importFixes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit f1abe3c

Please sign in to comment.