@@ -1008,9 +1008,15 @@ namespace ts {
10081008 return ts . toPath ( fileName , currentDirectory , getCanonicalFileName ) ;
10091009 }
10101010
1011+ function isValidSourceFileForEmit ( file : SourceFile ) {
1012+ // source file is allowed to be emitted and its not source of project reference redirect
1013+ return sourceFileMayBeEmitted ( file , options , isSourceFileFromExternalLibrary , getResolvedProjectReferenceToRedirect ) &&
1014+ ! isSourceOfProjectReferenceRedirect ( file . fileName ) ;
1015+ }
1016+
10111017 function getCommonSourceDirectory ( ) {
10121018 if ( commonSourceDirectory === undefined ) {
1013- const emittedFiles = filter ( files , file => sourceFileMayBeEmitted ( file , options , isSourceFileFromExternalLibrary , getResolvedProjectReferenceToRedirect ) ) ;
1019+ const emittedFiles = filter ( files , file => isValidSourceFileForEmit ( file ) ) ;
10141020 if ( options . rootDir && checkSourceFilesBelongToPath ( emittedFiles , options . rootDir ) ) {
10151021 // If a rootDir is specified use it as the commonSourceDirectory
10161022 commonSourceDirectory = getNormalizedAbsolutePath ( options . rootDir , currentDirectory ) ;
@@ -2933,8 +2939,7 @@ namespace ts {
29332939 const rootPaths = arrayToSet ( rootNames , toPath ) ;
29342940 for ( const file of files ) {
29352941 // Ignore file that is not emitted
2936- if ( ! sourceFileMayBeEmitted ( file , options , isSourceFileFromExternalLibrary , getResolvedProjectReferenceToRedirect ) ) continue ;
2937- if ( ! rootPaths . has ( file . path ) ) {
2942+ if ( isValidSourceFileForEmit ( file ) && ! rootPaths . has ( file . path ) ) {
29382943 addProgramDiagnosticAtRefPath (
29392944 file ,
29402945 rootPaths ,
0 commit comments