fix handling if there is no commonPrefix

This commit is contained in:
Klaus Meinhardt 2018-08-09 11:50:00 +02:00
parent 20442fe363
commit d2dc17d765
2 changed files with 3 additions and 6 deletions

View File

@ -407,11 +407,8 @@ namespace ts {
// directory: /a/b/c/d/e
// resolvedFileName: /a/b/foo.d.ts
// commonPrefix: /a/b
// for failed lookups use the root directory as commonPrefix
const commonPrefix = resolvedFileName ? getCommonPrefix(path, resolvedFileName) : path.substr(0, getRootLength(path));
if (!commonPrefix) {
return;
}
// for failed lookups cache the result for every directory up to root
const commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
let current = path;
while (current !== commonPrefix) {
const parent = getDirectoryPath(current);

View File

@ -262,7 +262,7 @@ namespace ts {
failedLookupLocations: [],
});
assert.isDefined(cache.get("c:/foo"));
assert.isUndefined(cache.get("c:/"));
assert.isDefined(cache.get("c:/"));
assert.isUndefined(cache.get("d:/"));
cache = resolutionCache.getOrCreateCacheForModuleName("f");