File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -407,18 +407,17 @@ namespace ts {
407407 // directory: /a/b/c/d/e
408408 // resolvedFileName: /a/b/foo.d.ts
409409 const commonPrefix = getCommonPrefix ( path , resolvedFileName ) ;
410+ if ( commonPrefix === undefined ) {
411+ return ;
412+ }
410413 let current = path ;
411- while ( true ) {
414+ while ( current !== commonPrefix ) {
412415 const parent = getDirectoryPath ( current ) ;
413416 if ( parent === current || directoryPathMap . has ( parent ) ) {
414417 break ;
415418 }
416419 directoryPathMap . set ( parent , result ) ;
417420 current = parent ;
418-
419- if ( current === commonPrefix ) {
420- break ;
421- }
422421 }
423422 }
424423
@@ -434,6 +433,10 @@ namespace ts {
434433 i ++ ;
435434 }
436435
436+ if ( i === directory . length && resolutionDirectory . length > i && resolutionDirectory [ i ] === directorySeparator ) {
437+ return directory ;
438+ }
439+
437440 // find last directory separator before position i
438441 const sep = directory . lastIndexOf ( directorySeparator , i ) ;
439442 if ( sep < 0 ) {
You can’t perform that action at this time.
0 commit comments