Inspect all possible module paths when looking for the best one to create a specifier with (#25850)

* Inspect all possible specifier paths when looking for the best one

* Add missing secondary option from test
This commit is contained in:
Wesley Wigham
2018-07-24 14:12:44 -07:00
committed by Wesley Wigham
parent bde711583c
commit a4d3bddf62
13 changed files with 118 additions and 145 deletions
+6 -1
View File
@@ -194,7 +194,12 @@ namespace ts.moduleSpecifiers {
const symlinks = mapDefined(files, sf =>
sf.resolvedModules && firstDefinedIterator(sf.resolvedModules.values(), res =>
res && res.resolvedFileName === importedFileName ? res.originalPath : undefined));
return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, getNormalizedAbsolutePath(importedFileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks;
const cwd = host.getCurrentDirectory ? host.getCurrentDirectory() : "";
const baseOptions = getAllModulePathsUsingIndirectSymlinks(files, getNormalizedAbsolutePath(importedFileName, cwd), getCanonicalFileName, host);
if (symlinks.length === 0) {
return baseOptions;
}
return deduplicate(concatenate(baseOptions, flatMap(symlinks, importedFileName => getAllModulePathsUsingIndirectSymlinks(files, getNormalizedAbsolutePath(importedFileName, cwd), getCanonicalFileName, host))));
}
function getRelativePathNParents(relativePath: string): number {