@@ -775,60 +775,62 @@ namespace ts {
775
775
776
776
// Get source file from normalized fileName
777
777
function findSourceFile ( fileName : string , isDefaultLib : boolean , refFile ?: SourceFile , refPos ?: number , refEnd ?: number ) : SourceFile {
778
- let canonicalName = host . getCanonicalFileName ( normalizeSlashes ( fileName ) ) ;
779
- if ( filesByName . contains ( canonicalName ) ) {
778
+ if ( filesByName . contains ( fileName ) ) {
780
779
// We've already looked for this file, use cached result
781
- return getSourceFileFromCache ( fileName , canonicalName , /*useAbsolutePath*/ false ) ;
780
+ return getSourceFileFromCache ( fileName , /*useAbsolutePath*/ false ) ;
781
+ }
782
+
783
+ let normalizedAbsolutePath = getNormalizedAbsolutePath ( fileName , host . getCurrentDirectory ( ) ) ;
784
+ if ( filesByName . contains ( normalizedAbsolutePath ) ) {
785
+ const file = getSourceFileFromCache ( normalizedAbsolutePath , /*useAbsolutePath*/ true ) ;
786
+ // we don't have resolution for this relative file name but the match was found by absolute file name
787
+ // store resolution for relative name as well
788
+ filesByName . set ( fileName , file ) ;
789
+ return file ;
782
790
}
783
- else {
784
- let normalizedAbsolutePath = getNormalizedAbsolutePath ( fileName , host . getCurrentDirectory ( ) ) ;
785
- let canonicalAbsolutePath = host . getCanonicalFileName ( normalizedAbsolutePath ) ;
786
- if ( filesByName . contains ( canonicalAbsolutePath ) ) {
787
- return getSourceFileFromCache ( normalizedAbsolutePath , canonicalAbsolutePath , /*useAbsolutePath*/ true ) ;
788
- }
789
791
790
- // We haven't looked for this file, do so now and cache result
791
- let file = host . getSourceFile ( fileName , options . target , hostErrorMessage => {
792
- if ( refFile !== undefined && refPos !== undefined && refEnd !== undefined ) {
793
- fileProcessingDiagnostics . add ( createFileDiagnostic ( refFile , refPos , refEnd - refPos ,
794
- Diagnostics . Cannot_read_file_0_Colon_1 , fileName , hostErrorMessage ) ) ;
795
- }
796
- else {
797
- fileProcessingDiagnostics . add ( createCompilerDiagnostic ( Diagnostics . Cannot_read_file_0_Colon_1 , fileName , hostErrorMessage ) ) ;
798
- }
799
- } ) ;
800
- filesByName . set ( canonicalName , file ) ;
801
- if ( file ) {
802
- skipDefaultLib = skipDefaultLib || file . hasNoDefaultLib ;
792
+ // We haven't looked for this file, do so now and cache result
793
+ let file = host . getSourceFile ( fileName , options . target , hostErrorMessage => {
794
+ if ( refFile !== undefined && refPos !== undefined && refEnd !== undefined ) {
795
+ fileProcessingDiagnostics . add ( createFileDiagnostic ( refFile , refPos , refEnd - refPos ,
796
+ Diagnostics . Cannot_read_file_0_Colon_1 , fileName , hostErrorMessage ) ) ;
797
+ }
798
+ else {
799
+ fileProcessingDiagnostics . add ( createCompilerDiagnostic ( Diagnostics . Cannot_read_file_0_Colon_1 , fileName , hostErrorMessage ) ) ;
800
+ }
801
+ } ) ;
802
+
803
+ filesByName . set ( fileName , file ) ;
804
+ if ( file ) {
805
+ skipDefaultLib = skipDefaultLib || file . hasNoDefaultLib ;
803
806
804
- // Set the source file for normalized absolute path
805
- filesByName . set ( canonicalAbsolutePath , file ) ;
806
-
807
- let basePath = getDirectoryPath ( fileName ) ;
808
- if ( ! options . noResolve ) {
809
- processReferencedFiles ( file , basePath ) ;
810
- }
807
+ // Set the source file for normalized absolute path
808
+ filesByName . set ( normalizedAbsolutePath , file ) ;
809
+
810
+ let basePath = getDirectoryPath ( fileName ) ;
811
+ if ( ! options . noResolve ) {
812
+ processReferencedFiles ( file , basePath ) ;
813
+ }
811
814
812
- // always process imported modules to record module name resolutions
813
- processImportedModules ( file , basePath ) ;
815
+ // always process imported modules to record module name resolutions
816
+ processImportedModules ( file , basePath ) ;
814
817
815
- if ( isDefaultLib ) {
816
- file . isDefaultLib = true ;
817
- files . unshift ( file ) ;
818
- }
819
- else {
820
- files . push ( file ) ;
821
- }
818
+ if ( isDefaultLib ) {
819
+ file . isDefaultLib = true ;
820
+ files . unshift ( file ) ;
821
+ }
822
+ else {
823
+ files . push ( file ) ;
822
824
}
823
-
824
- return file ;
825
825
}
826
826
827
- function getSourceFileFromCache ( fileName : string , canonicalName : string , useAbsolutePath : boolean ) : SourceFile {
828
- let file = filesByName . get ( canonicalName ) ;
827
+ return file ;
828
+
829
+ function getSourceFileFromCache ( fileName : string , useAbsolutePath : boolean ) : SourceFile {
830
+ let file = filesByName . get ( fileName ) ;
829
831
if ( file && host . useCaseSensitiveFileNames ( ) ) {
830
832
let sourceFileName = useAbsolutePath ? getNormalizedAbsolutePath ( file . fileName , host . getCurrentDirectory ( ) ) : file . fileName ;
831
- if ( canonicalName !== sourceFileName ) {
833
+ if ( normalizeSlashes ( fileName ) !== normalizeSlashes ( sourceFileName ) ) {
832
834
if ( refFile !== undefined && refPos !== undefined && refEnd !== undefined ) {
833
835
fileProcessingDiagnostics . add ( createFileDiagnostic ( refFile , refPos , refEnd - refPos ,
834
836
Diagnostics . File_name_0_differs_from_already_included_file_name_1_only_in_casing , fileName , sourceFileName ) ) ;
@@ -862,8 +864,8 @@ namespace ts {
862
864
const importedFile = findModuleSourceFile ( resolution . resolvedFileName , file . imports [ i ] ) ;
863
865
if ( importedFile && resolution . isExternalLibraryImport ) {
864
866
if ( ! isExternalModule ( importedFile ) ) {
865
- let start = getTokenPosOfNode ( file . imports [ i ] , file )
866
- fileProcessingDiagnostics . add ( createFileDiagnostic ( file , start , file . imports [ i ] . end - start , Diagnostics . Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition , importedFile . fileName ) ) ;
867
+ let start = getTokenPosOfNode ( file . imports [ i ] , file )
868
+ fileProcessingDiagnostics . add ( createFileDiagnostic ( file , start , file . imports [ i ] . end - start , Diagnostics . Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition , importedFile . fileName ) ) ;
867
869
}
868
870
else if ( ! fileExtensionIs ( importedFile . fileName , ".d.ts" ) ) {
869
871
let start = getTokenPosOfNode ( file . imports [ i ] , file )
0 commit comments