@@ -824,7 +824,7 @@ namespace ts {
824
824
* - false if sourceFile missing for source of project reference redirect
825
825
* - undefined otherwise
826
826
*/
827
- const filesByName = new Map < string , SourceFile | false | undefined > ( ) ;
827
+ const filesByName = new Map < string , SourceFile | false | 0 > ( ) ;
828
828
let missingFilePaths : readonly Path [ ] | undefined ;
829
829
// stores 'filename -> file association' ignoring case
830
830
// used to track cases when two file names differ only in casing
@@ -921,7 +921,7 @@ namespace ts {
921
921
}
922
922
}
923
923
924
- missingFilePaths = arrayFrom ( mapDefinedIterator ( filesByName . entries ( ) , ( [ path , file ] ) => file === undefined ? path as Path : undefined ) ) ;
924
+ missingFilePaths = arrayFrom ( mapDefinedIterator ( filesByName . entries ( ) , ( [ path , file ] ) => file === 0 ? path as Path : undefined ) ) ;
925
925
files = stableSort ( processingDefaultLibFiles , compareDefaultLibFiles ) . concat ( processingOtherFiles ) ;
926
926
processingDefaultLibFiles = undefined ;
927
927
processingOtherFiles = undefined ;
@@ -1568,7 +1568,7 @@ namespace ts {
1568
1568
}
1569
1569
return ;
1570
1570
}
1571
- filesByName . set ( path , filesByName . get ( oldFile . path ) ) ;
1571
+ filesByName . set ( path , filesByName . get ( oldFile . path ) ! ) ;
1572
1572
} ) ;
1573
1573
1574
1574
files = newSourceFiles ;
@@ -1658,8 +1658,8 @@ namespace ts {
1658
1658
( _ref , index ) => resolvedProjectReferences ! [ index ] ?. commandLine ,
1659
1659
fileName => {
1660
1660
const path = toPath ( fileName ) ;
1661
- const sourceFile = getSourceFileByPath ( path ) ;
1662
- return sourceFile ? sourceFile . text : filesByName . has ( path ) ? undefined : host . readFile ( path ) ;
1661
+ const sourceFile = filesByName . get ( path ) ;
1662
+ return sourceFile ? sourceFile . text : sourceFile !== undefined ? undefined : host . readFile ( path ) ;
1663
1663
}
1664
1664
) ;
1665
1665
}
@@ -2484,13 +2484,13 @@ namespace ts {
2484
2484
}
2485
2485
}
2486
2486
const originalFileName = fileName ;
2487
- if ( filesByName . has ( path ) ) {
2488
- const file = filesByName . get ( path ) ;
2489
- addFileToRefFileMap ( fileName , file || undefined , refFile ) ;
2487
+ const cachedFile = filesByName . get ( path ) ;
2488
+ if ( cachedFile !== undefined ) {
2489
+ addFileToRefFileMap ( fileName , cachedFile || undefined , refFile ) ;
2490
2490
// try to check if we've already seen this file but with a different casing in path
2491
2491
// NOTE: this only makes sense for case-insensitive file systems, and only on files which are not redirected
2492
- if ( file && options . forceConsistentCasingInFileNames ) {
2493
- const checkedName = file . fileName ;
2492
+ if ( cachedFile && options . forceConsistentCasingInFileNames ) {
2493
+ const checkedName = cachedFile . fileName ;
2494
2494
const isRedirect = toPath ( checkedName ) !== toPath ( fileName ) ;
2495
2495
if ( isRedirect ) {
2496
2496
fileName = getProjectReferenceRedirect ( fileName ) || fileName ;
@@ -2499,34 +2499,34 @@ namespace ts {
2499
2499
const checkedAbsolutePath = getNormalizedAbsolutePathWithoutRoot ( checkedName , currentDirectory ) ;
2500
2500
const inputAbsolutePath = getNormalizedAbsolutePathWithoutRoot ( fileName , currentDirectory ) ;
2501
2501
if ( checkedAbsolutePath !== inputAbsolutePath ) {
2502
- reportFileNamesDifferOnlyInCasingError ( fileName , file , refFile ) ;
2502
+ reportFileNamesDifferOnlyInCasingError ( fileName , cachedFile , refFile ) ;
2503
2503
}
2504
2504
}
2505
2505
2506
2506
// If the file was previously found via a node_modules search, but is now being processed as a root file,
2507
2507
// then everything it sucks in may also be marked incorrectly, and needs to be checked again.
2508
- if ( file && sourceFilesFoundSearchingNodeModules . get ( file . path ) && currentNodeModulesDepth === 0 ) {
2509
- sourceFilesFoundSearchingNodeModules . set ( file . path , false ) ;
2508
+ if ( cachedFile && sourceFilesFoundSearchingNodeModules . get ( cachedFile . path ) && currentNodeModulesDepth === 0 ) {
2509
+ sourceFilesFoundSearchingNodeModules . set ( cachedFile . path , false ) ;
2510
2510
if ( ! options . noResolve ) {
2511
- processReferencedFiles ( file , isDefaultLib ) ;
2512
- processTypeReferenceDirectives ( file ) ;
2511
+ processReferencedFiles ( cachedFile , isDefaultLib ) ;
2512
+ processTypeReferenceDirectives ( cachedFile ) ;
2513
2513
}
2514
2514
if ( ! options . noLib ) {
2515
- processLibReferenceDirectives ( file ) ;
2515
+ processLibReferenceDirectives ( cachedFile ) ;
2516
2516
}
2517
2517
2518
- modulesWithElidedImports . set ( file . path , false ) ;
2519
- processImportedModules ( file ) ;
2518
+ modulesWithElidedImports . set ( cachedFile . path , false ) ;
2519
+ processImportedModules ( cachedFile ) ;
2520
2520
}
2521
2521
// See if we need to reprocess the imports due to prior skipped imports
2522
- else if ( file && modulesWithElidedImports . get ( file . path ) ) {
2522
+ else if ( cachedFile && modulesWithElidedImports . get ( cachedFile . path ) ) {
2523
2523
if ( currentNodeModulesDepth < maxNodeModuleJsDepth ) {
2524
- modulesWithElidedImports . set ( file . path , false ) ;
2525
- processImportedModules ( file ) ;
2524
+ modulesWithElidedImports . set ( cachedFile . path , false ) ;
2525
+ processImportedModules ( cachedFile ) ;
2526
2526
}
2527
2527
}
2528
2528
2529
- return file || undefined ;
2529
+ return cachedFile || undefined ;
2530
2530
}
2531
2531
2532
2532
let redirectedPath : Path | undefined ;
@@ -2639,11 +2639,11 @@ namespace ts {
2639
2639
2640
2640
function addFileToFilesByName ( file : SourceFile | undefined , path : Path , redirectedPath : Path | undefined ) {
2641
2641
if ( redirectedPath ) {
2642
- filesByName . set ( redirectedPath , file ) ;
2642
+ filesByName . set ( redirectedPath , file || 0 ) ;
2643
2643
filesByName . set ( path , file || false ) ;
2644
2644
}
2645
2645
else {
2646
- filesByName . set ( path , file ) ;
2646
+ filesByName . set ( path , file || 0 ) ;
2647
2647
}
2648
2648
}
2649
2649
0 commit comments