@@ -280,6 +280,11 @@ namespace ts {
280280 }
281281 const nodeModulesAtTypes = combinePaths ( "node_modules" , "@types" ) ;
282282
283+ function arePathsEqual ( path1 : string , path2 : string , host : ModuleResolutionHost ) : boolean {
284+ const useCaseSensitiveFileNames = typeof host . useCaseSensitiveFileNames === "function" ? host . useCaseSensitiveFileNames ( ) : host . useCaseSensitiveFileNames ;
285+ return comparePaths ( path1 , path2 , ! useCaseSensitiveFileNames ) === Comparison . EqualTo ;
286+ }
287+
283288 /**
284289 * @param {string | undefined } containingFile - file that contains type reference directive, can be undefined if containing file is unknown.
285290 * This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
@@ -343,7 +348,7 @@ namespace ts {
343348 resolvedTypeReferenceDirective = {
344349 primary,
345350 resolvedFileName,
346- originalPath : fileName === resolvedFileName ? undefined : fileName ,
351+ originalPath : arePathsEqual ( fileName , resolvedFileName , host ) ? undefined : fileName ,
347352 packageId,
348353 isExternalLibraryImport : pathContainsNodeModules ( fileName ) ,
349354 } ;
@@ -1072,12 +1077,6 @@ namespace ts {
10721077 return resolvedModule . resolvedFileName ;
10731078 }
10741079
1075- /* @internal */
1076- export function tryResolveJSModule ( moduleName : string , initialDir : string , host : ModuleResolutionHost ) : string | undefined {
1077- const { resolvedModule } = tryResolveJSModuleWorker ( moduleName , initialDir , host ) ;
1078- return resolvedModule && resolvedModule . resolvedFileName ;
1079- }
1080-
10811080 const jsOnlyExtensions = [ Extensions . JavaScript ] ;
10821081 const tsExtensions = [ Extensions . TypeScript , Extensions . JavaScript ] ;
10831082 const tsPlusJsonExtensions = [ ...tsExtensions , Extensions . Json ] ;
@@ -1118,7 +1117,7 @@ namespace ts {
11181117 let resolvedValue = resolved . value ;
11191118 if ( ! compilerOptions . preserveSymlinks && resolvedValue && ! resolvedValue . originalPath ) {
11201119 const path = realPath ( resolvedValue . path , host , traceEnabled ) ;
1121- const originalPath = path === resolvedValue . path ? undefined : resolvedValue . path ;
1120+ const originalPath = arePathsEqual ( path , resolvedValue . path , host ) ? undefined : resolvedValue . path ;
11221121 resolvedValue = { ...resolvedValue , path, originalPath } ;
11231122 }
11241123 // For node_modules lookups, get the real path so that multiple accesses to an `npm link`-ed module do not create duplicate files.
0 commit comments