@@ -337,6 +337,7 @@ namespace ts {
337337 getAccessileSortedChildDirectories ( path : string ) : ReadonlyArray < string > ;
338338 directoryExists ( dir : string ) : boolean ;
339339 filePathComparer : Comparer < string > ;
340+ realpath ( s : string ) : string ;
340341 }
341342
342343 /**
@@ -392,9 +393,12 @@ namespace ts {
392393 function watchChildDirectories ( parentDir : string , existingChildWatches : ChildWatches , callback : DirectoryWatcherCallback ) : ChildWatches {
393394 let newChildWatches : DirectoryWatcher [ ] | undefined ;
394395 enumerateInsertsAndDeletes < string , DirectoryWatcher > (
395- host . directoryExists ( parentDir ) ? host . getAccessileSortedChildDirectories ( parentDir ) : emptyArray ,
396+ host . directoryExists ( parentDir ) ? mapDefined ( host . getAccessileSortedChildDirectories ( parentDir ) , child => {
397+ const childFullName = getNormalizedAbsolutePath ( child , parentDir ) ;
398+ return host . filePathComparer ( childFullName , host . realpath ( childFullName ) ) === Comparison . EqualTo ? childFullName : undefined ;
399+ } ) : emptyArray ,
396400 existingChildWatches ,
397- ( child , childWatcher ) => host . filePathComparer ( getNormalizedAbsolutePath ( child , parentDir ) , childWatcher . dirName ) ,
401+ ( child , childWatcher ) => host . filePathComparer ( child , childWatcher . dirName ) ,
398402 createAndAddChildDirectoryWatcher ,
399403 closeFileWatcher ,
400404 addChildDirectoryWatcher
@@ -406,7 +410,7 @@ namespace ts {
406410 * Create new childDirectoryWatcher and add it to the new ChildDirectoryWatcher list
407411 */
408412 function createAndAddChildDirectoryWatcher ( childName : string ) {
409- const result = createDirectoryWatcher ( getNormalizedAbsolutePath ( childName , parentDir ) , callback ) ;
413+ const result = createDirectoryWatcher ( childName , callback ) ;
410414 addChildDirectoryWatcher ( result ) ;
411415 }
412416
@@ -601,14 +605,7 @@ namespace ts {
601605 exit ( exitCode ?: number ) : void {
602606 process . exit ( exitCode ) ;
603607 } ,
604- realpath ( path : string ) : string {
605- try {
606- return _fs . realpathSync ( path ) ;
607- }
608- catch {
609- return path ;
610- }
611- } ,
608+ realpath,
612609 debugMode : some ( < string [ ] > process . execArgv , arg => / ^ - - ( i n s p e c t | d e b u g ) ( - b r k ) ? ( = \d + ) ? $ / i. test ( arg ) ) ,
613610 tryEnableSourceMapsForHost ( ) {
614611 try {
@@ -700,7 +697,8 @@ namespace ts {
700697 filePathComparer : useCaseSensitiveFileNames ? compareStringsCaseSensitive : compareStringsCaseInsensitive ,
701698 directoryExists,
702699 getAccessileSortedChildDirectories : path => getAccessibleFileSystemEntries ( path ) . directories ,
703- watchDirectory
700+ watchDirectory,
701+ realpath
704702 } ) ;
705703
706704 return ( directoryName , callback , recursive ) => {
@@ -1043,6 +1041,15 @@ namespace ts {
10431041 return filter < string > ( _fs . readdirSync ( path ) , dir => fileSystemEntryExists ( combinePaths ( path , dir ) , FileSystemEntryKind . Directory ) ) ;
10441042 }
10451043
1044+ function realpath ( path : string ) : string {
1045+ try {
1046+ return _fs . realpathSync ( path ) ;
1047+ }
1048+ catch {
1049+ return path ;
1050+ }
1051+ }
1052+
10461053 function getModifiedTime ( path : string ) {
10471054 try {
10481055 return _fs . statSync ( path ) . mtime ;
0 commit comments