File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -403,10 +403,12 @@ namespace ts {
403
403
404
404
const resolvedFileName = result . resolvedModule && result . resolvedModule . resolvedFileName ;
405
405
// find common prefix between directory and resolved file name
406
- // this common prefix should be the shorted path that has the same resolution
406
+ // this common prefix should be the shortest path that has the same resolution
407
407
// directory: /a/b/c/d/e
408
408
// resolvedFileName: /a/b/foo.d.ts
409
- const commonPrefix = getCommonPrefix ( path , resolvedFileName ) ;
409
+ // commonPrefix: /a/b
410
+ // for failed lookups use the root directory as commonPrefix
411
+ const commonPrefix = resolvedFileName ? getCommonPrefix ( path , resolvedFileName ) : path . substr ( 0 , getRootLength ( path ) ) ;
410
412
if ( ! commonPrefix ) {
411
413
return ;
412
414
}
@@ -421,10 +423,7 @@ namespace ts {
421
423
}
422
424
}
423
425
424
- function getCommonPrefix ( directory : Path , resolution : string | undefined ) {
425
- if ( resolution === undefined ) {
426
- return undefined ;
427
- }
426
+ function getCommonPrefix ( directory : Path , resolution : string ) {
428
427
const resolutionDirectory = toPath ( getDirectoryPath ( resolution ) , currentDirectory , getCanonicalFileName ) ;
429
428
430
429
let current = directory ;
Original file line number Diff line number Diff line change @@ -264,6 +264,16 @@ namespace ts {
264
264
assert . isDefined ( cache . get ( "c:/foo" ) ) ;
265
265
assert . isUndefined ( cache . get ( "c:/" ) ) ;
266
266
assert . isUndefined ( cache . get ( "d:/" ) ) ;
267
+
268
+ cache = resolutionCache . getOrCreateCacheForModuleName ( "f" ) ;
269
+ cache . set ( "/foo/bar/baz" , {
270
+ resolvedModule : undefined ,
271
+ failedLookupLocations : [ ] ,
272
+ } ) ;
273
+ assert . isDefined ( cache . get ( "/foo/bar/baz" ) ) ;
274
+ assert . isDefined ( cache . get ( "/foo/bar" ) ) ;
275
+ assert . isDefined ( cache . get ( "/foo" ) ) ;
276
+ assert . isDefined ( cache . get ( "/" ) ) ;
267
277
} ) ;
268
278
269
279
it ( "load module as file - ts files not loaded" , ( ) => {
You can’t perform that action at this time.
0 commit comments