@@ -485,11 +485,11 @@ namespace ts {
485485
486486 function sourceFileNotUptoDate ( sourceFile : SourceFile ) {
487487 return ! sourceFileVersionUptoDate ( sourceFile ) ||
488- hasInvalidatedResolution ( sourceFile . resolvedPath || sourceFile . path ) ;
488+ hasInvalidatedResolution ( sourceFile . resolvedPath ) ;
489489 }
490490
491491 function sourceFileVersionUptoDate ( sourceFile : SourceFile ) {
492- return sourceFile . version === getSourceVersion ( sourceFile . resolvedPath || sourceFile . path ) ;
492+ return sourceFile . version === getSourceVersion ( sourceFile . resolvedPath ) ;
493493 }
494494
495495 function projectReferenceUptoDate ( oldRef : ProjectReference , newRef : ProjectReference , index : number ) {
@@ -1079,7 +1079,7 @@ namespace ts {
10791079
10801080 for ( const oldSourceFile of oldSourceFiles ) {
10811081 let newSourceFile = host . getSourceFileByPath
1082- ? host . getSourceFileByPath ( oldSourceFile . fileName , oldSourceFile . resolvedPath || oldSourceFile . path , options . target ! , /*onError*/ undefined , shouldCreateNewSourceFile )
1082+ ? host . getSourceFileByPath ( oldSourceFile . fileName , oldSourceFile . resolvedPath , options . target ! , /*onError*/ undefined , shouldCreateNewSourceFile )
10831083 : host . getSourceFile ( oldSourceFile . fileName , options . target ! , /*onError*/ undefined , shouldCreateNewSourceFile ) ; // TODO: GH#18217
10841084
10851085 if ( ! newSourceFile ) {
@@ -1110,7 +1110,11 @@ namespace ts {
11101110 fileChanged = newSourceFile !== oldSourceFile ;
11111111 }
11121112
1113+ // Since the project references havent changed, its right to set originalFileName and resolvedPath here
11131114 newSourceFile . path = oldSourceFile . path ;
1115+ newSourceFile . originalFileName = oldSourceFile . originalFileName ;
1116+ newSourceFile . resolvedPath = oldSourceFile . resolvedPath ;
1117+ newSourceFile . fileName = oldSourceFile . fileName ;
11141118 filePaths . push ( newSourceFile . path ) ;
11151119
11161120 const packageName = oldProgram . sourceFileToPackageName . get ( oldSourceFile . path ) ;
@@ -1187,7 +1191,7 @@ namespace ts {
11871191 modifiedFilePaths = modifiedSourceFiles . map ( f => f . newFile . path ) ;
11881192 // try to verify results of module resolution
11891193 for ( const { oldFile : oldSourceFile , newFile : newSourceFile } of modifiedSourceFiles ) {
1190- const newSourceFilePath = getNormalizedAbsolutePath ( newSourceFile . fileName , currentDirectory ) ;
1194+ const newSourceFilePath = getNormalizedAbsolutePath ( newSourceFile . originalFileName , currentDirectory ) ;
11911195 if ( resolveModuleNamesWorker ) {
11921196 const moduleNames = getModuleNames ( newSourceFile ) ;
11931197 const oldProgramState : OldProgramState = { program : oldProgram , oldSourceFile, modifiedFilePaths } ;
@@ -2040,6 +2044,7 @@ namespace ts {
20402044
20412045 // Get source file from normalized fileName
20422046 function findSourceFile ( fileName : string , path : Path , isDefaultLib : boolean , ignoreNoDefaultLib : boolean , refFile : SourceFile , refPos : number , refEnd : number , packageId : PackageId | undefined ) : SourceFile | undefined {
2047+ const originalFileName = fileName ;
20432048 if ( filesByName . has ( path ) ) {
20442049 const file = filesByName . get ( path ) ;
20452050 // try to check if we've already seen this file but with a different casing in path
@@ -2136,6 +2141,7 @@ namespace ts {
21362141 sourceFilesFoundSearchingNodeModules . set ( path , currentNodeModulesDepth > 0 ) ;
21372142 file . path = path ;
21382143 file . resolvedPath = toPath ( fileName ) ;
2144+ file . originalFileName = originalFileName ;
21392145
21402146 if ( host . useCaseSensitiveFileNames ( ) ) {
21412147 const pathLowerCase = path . toLowerCase ( ) ;
@@ -2191,7 +2197,7 @@ namespace ts {
21912197
21922198 function processReferencedFiles ( file : SourceFile , isDefaultLib : boolean ) {
21932199 forEach ( file . referencedFiles , ref => {
2194- const referencedFileName = resolveTripleslashReference ( ref . fileName , file . fileName ) ;
2200+ const referencedFileName = resolveTripleslashReference ( ref . fileName , file . originalFileName ) ;
21952201 processSourceFile ( referencedFileName , isDefaultLib , /*ignoreNoDefaultLib*/ false , /*packageId*/ undefined , file , ref . pos , ref . end ) ;
21962202 } ) ;
21972203 }
@@ -2203,7 +2209,7 @@ namespace ts {
22032209 return ;
22042210 }
22052211
2206- const resolutions = resolveTypeReferenceDirectiveNamesWorker ( typeDirectives , file . fileName ) ;
2212+ const resolutions = resolveTypeReferenceDirectiveNamesWorker ( typeDirectives , file . originalFileName ) ;
22072213
22082214 for ( let i = 0 ; i < typeDirectives . length ; i ++ ) {
22092215 const ref = file . typeReferenceDirectives [ i ] ;
@@ -2299,7 +2305,7 @@ namespace ts {
22992305 // Because global augmentation doesn't have string literal name, we can check for global augmentation as such.
23002306 const moduleNames = getModuleNames ( file ) ;
23012307 const oldProgramState : OldProgramState = { program : oldProgram , oldSourceFile : oldProgram && oldProgram . getSourceFile ( file . fileName ) , modifiedFilePaths } ;
2302- const resolutions = resolveModuleNamesReusingOldState ( moduleNames , getNormalizedAbsolutePath ( file . fileName , currentDirectory ) , file , oldProgramState ) ;
2308+ const resolutions = resolveModuleNamesReusingOldState ( moduleNames , getNormalizedAbsolutePath ( file . originalFileName , currentDirectory ) , file , oldProgramState ) ;
23032309 Debug . assert ( resolutions . length === moduleNames . length ) ;
23042310 for ( let i = 0 ; i < moduleNames . length ; i ++ ) {
23052311 const resolution = resolutions [ i ] ;
0 commit comments