@@ -1160,21 +1160,20 @@ namespace ts {
11601160
11611161 // The originalFileName could not be actual source file name if file found was d.ts from referecned project
11621162 // So in this case try to look up if this is output from referenced project, if it is use the redirected project in that case
1163- const resultFromDts = getRedirectReferenceForResolutionFromSourceOfProject ( file . originalFileName , file . path ) ;
1163+ const resultFromDts = getRedirectReferenceForResolutionFromSourceOfProject ( file . path ) ;
11641164 if ( resultFromDts ) return resultFromDts ;
11651165
11661166 // If preserveSymlinks is true, module resolution wont jump the symlink
11671167 // but the resolved real path may be the .d.ts from project reference
11681168 // Note:: Currently we try the real path only if the
11691169 // file is from node_modules to avoid having to run real path on all file paths
11701170 if ( ! host . realpath || ! options . preserveSymlinks || ! stringContains ( file . originalFileName , nodeModulesPathPart ) ) return undefined ;
1171- const realDeclarationFileName = host . realpath ( file . originalFileName ) ;
1172- const realDeclarationPath = toPath ( realDeclarationFileName ) ;
1173- return realDeclarationPath === file . path ? undefined : getRedirectReferenceForResolutionFromSourceOfProject ( realDeclarationFileName , realDeclarationPath ) ;
1171+ const realDeclarationPath = toPath ( host . realpath ( file . originalFileName ) ) ;
1172+ return realDeclarationPath === file . path ? undefined : getRedirectReferenceForResolutionFromSourceOfProject ( realDeclarationPath ) ;
11741173 }
11751174
1176- function getRedirectReferenceForResolutionFromSourceOfProject ( fileName : string , filePath : Path ) {
1177- const source = getSourceOfProjectReferenceRedirect ( fileName ) ;
1175+ function getRedirectReferenceForResolutionFromSourceOfProject ( filePath : Path ) {
1176+ const source = getSourceOfProjectReferenceRedirect ( filePath ) ;
11781177 if ( isString ( source ) ) return getResolvedProjectReferenceToRedirect ( source ) ;
11791178 if ( ! source ) return undefined ;
11801179 // Output of .d.ts file so return resolved ref that matches the out file name
@@ -2465,7 +2464,7 @@ namespace ts {
24652464 function processSourceFile ( fileName : string , isDefaultLib : boolean , ignoreNoDefaultLib : boolean , packageId : PackageId | undefined , reason : FileIncludeReason ) : void {
24662465 getSourceFileFromReferenceWorker (
24672466 fileName ,
2468- fileName => findSourceFile ( fileName , toPath ( fileName ) , isDefaultLib , ignoreNoDefaultLib , reason , packageId ) , // TODO: GH#18217
2467+ fileName => findSourceFile ( fileName , isDefaultLib , ignoreNoDefaultLib , reason , packageId ) , // TODO: GH#18217
24692468 ( diagnostic , ...args ) => addFilePreprocessingFileExplainingDiagnostic ( /*file*/ undefined , reason , diagnostic , args ) ,
24702469 reason
24712470 ) ;
@@ -2507,20 +2506,21 @@ namespace ts {
25072506 }
25082507
25092508 // Get source file from normalized fileName
2510- function findSourceFile ( fileName : string , path : Path , isDefaultLib : boolean , ignoreNoDefaultLib : boolean , reason : FileIncludeReason , packageId : PackageId | undefined ) : SourceFile | undefined {
2509+ function findSourceFile ( fileName : string , isDefaultLib : boolean , ignoreNoDefaultLib : boolean , reason : FileIncludeReason , packageId : PackageId | undefined ) : SourceFile | undefined {
25112510 tracing ?. push ( tracing . Phase . Program , "findSourceFile" , {
25122511 fileName,
25132512 isDefaultLib : isDefaultLib || undefined ,
25142513 fileIncludeKind : ( FileIncludeKind as any ) [ reason . kind ] ,
25152514 } ) ;
2516- const result = findSourceFileWorker ( fileName , path , isDefaultLib , ignoreNoDefaultLib , reason , packageId ) ;
2515+ const result = findSourceFileWorker ( fileName , isDefaultLib , ignoreNoDefaultLib , reason , packageId ) ;
25172516 tracing ?. pop ( ) ;
25182517 return result ;
25192518 }
25202519
2521- function findSourceFileWorker ( fileName : string , path : Path , isDefaultLib : boolean , ignoreNoDefaultLib : boolean , reason : FileIncludeReason , packageId : PackageId | undefined ) : SourceFile | undefined {
2520+ function findSourceFileWorker ( fileName : string , isDefaultLib : boolean , ignoreNoDefaultLib : boolean , reason : FileIncludeReason , packageId : PackageId | undefined ) : SourceFile | undefined {
2521+ const path = toPath ( fileName ) ;
25222522 if ( useSourceOfProjectReferenceRedirect ) {
2523- let source = getSourceOfProjectReferenceRedirect ( fileName ) ;
2523+ let source = getSourceOfProjectReferenceRedirect ( path ) ;
25242524 // If preserveSymlinks is true, module resolution wont jump the symlink
25252525 // but the resolved real path may be the .d.ts from project reference
25262526 // Note:: Currently we try the real path only if the
@@ -2530,12 +2530,12 @@ namespace ts {
25302530 options . preserveSymlinks &&
25312531 isDeclarationFileName ( fileName ) &&
25322532 stringContains ( fileName , nodeModulesPathPart ) ) {
2533- const realPath = host . realpath ( fileName ) ;
2534- if ( realPath !== fileName ) source = getSourceOfProjectReferenceRedirect ( realPath ) ;
2533+ const realPath = toPath ( host . realpath ( fileName ) ) ;
2534+ if ( realPath !== path ) source = getSourceOfProjectReferenceRedirect ( realPath ) ;
25352535 }
25362536 if ( source ) {
25372537 const file = isString ( source ) ?
2538- findSourceFile ( source , toPath ( source ) , isDefaultLib , ignoreNoDefaultLib , reason , packageId ) :
2538+ findSourceFile ( source , isDefaultLib , ignoreNoDefaultLib , reason , packageId ) :
25392539 undefined ;
25402540 if ( file ) addFileToFilesByName ( file , path , /*redirectedPath*/ undefined ) ;
25412541 return file ;
@@ -2743,8 +2743,8 @@ namespace ts {
27432743 return ts . forEachResolvedProjectReference ( resolvedProjectReferences , cb ) ;
27442744 }
27452745
2746- function getSourceOfProjectReferenceRedirect ( file : string ) {
2747- if ( ! isDeclarationFileName ( file ) ) return undefined ;
2746+ function getSourceOfProjectReferenceRedirect ( path : Path ) {
2747+ if ( ! isDeclarationFileName ( path ) ) return undefined ;
27482748 if ( mapFromToProjectReferenceRedirectSource === undefined ) {
27492749 mapFromToProjectReferenceRedirectSource = new Map ( ) ;
27502750 forEachResolvedProjectReference ( resolvedRef => {
@@ -2765,7 +2765,7 @@ namespace ts {
27652765 }
27662766 } ) ;
27672767 }
2768- return mapFromToProjectReferenceRedirectSource . get ( toPath ( file ) ) ;
2768+ return mapFromToProjectReferenceRedirectSource . get ( path ) ;
27692769 }
27702770
27712771 function isSourceOfProjectReferenceRedirect ( fileName : string ) {
@@ -2947,10 +2947,8 @@ namespace ts {
29472947 modulesWithElidedImports . set ( file . path , true ) ;
29482948 }
29492949 else if ( shouldAddFile ) {
2950- const path = toPath ( resolvedFileName ) ;
29512950 findSourceFile (
29522951 resolvedFileName ,
2953- path ,
29542952 /*isDefaultLib*/ false ,
29552953 /*ignoreNoDefaultLib*/ false ,
29562954 { kind : FileIncludeKind . Import , file : file . path , index, } ,
@@ -3684,7 +3682,7 @@ namespace ts {
36843682 useSourceOfProjectReferenceRedirect : boolean ;
36853683 toPath ( fileName : string ) : Path ;
36863684 getResolvedProjectReferences ( ) : readonly ( ResolvedProjectReference | undefined ) [ ] | undefined ;
3687- getSourceOfProjectReferenceRedirect ( fileName : string ) : SourceOfProjectReferenceRedirect | undefined ;
3685+ getSourceOfProjectReferenceRedirect ( path : Path ) : SourceOfProjectReferenceRedirect | undefined ;
36883686 forEachResolvedProjectReference < T > ( cb : ( resolvedProjectReference : ResolvedProjectReference ) => T | undefined ) : T | undefined ;
36893687 }
36903688
@@ -3771,7 +3769,7 @@ namespace ts {
37713769 }
37723770
37733771 function fileExistsIfProjectReferenceDts ( file : string ) {
3774- const source = host . getSourceOfProjectReferenceRedirect ( file ) ;
3772+ const source = host . getSourceOfProjectReferenceRedirect ( host . toPath ( file ) ) ;
37753773 return source !== undefined ?
37763774 isString ( source ) ? originalFileExists . call ( host . compilerHost , source ) : true :
37773775 undefined ;
0 commit comments