@@ -3152,26 +3152,38 @@ namespace ts {
31523152 return referencePath ? ensurePathIsNonModuleName ( extensionless ) : extensionless ;
31533153 }
31543154
3155- export function getOwnEmitOutputFilePath ( sourceFile : SourceFile , host : EmitHost , extension : string ) {
3155+ export function getOwnEmitOutputFilePath ( fileName : string , host : EmitHost , extension : string ) {
31563156 const compilerOptions = host . getCompilerOptions ( ) ;
31573157 let emitOutputFilePathWithoutExtension : string ;
31583158 if ( compilerOptions . outDir ) {
3159- emitOutputFilePathWithoutExtension = removeFileExtension ( getSourceFilePathInNewDir ( sourceFile , host , compilerOptions . outDir ) ) ;
3159+ emitOutputFilePathWithoutExtension = removeFileExtension ( getSourceFilePathInNewDir ( fileName , host , compilerOptions . outDir ) ) ;
31603160 }
31613161 else {
3162- emitOutputFilePathWithoutExtension = removeFileExtension ( sourceFile . fileName ) ;
3162+ emitOutputFilePathWithoutExtension = removeFileExtension ( fileName ) ;
31633163 }
31643164
31653165 return emitOutputFilePathWithoutExtension + extension ;
31663166 }
31673167
3168- export function getDeclarationEmitOutputFilePath ( sourceFile : SourceFile , host : EmitHost ) {
3168+ export function getDeclarationEmitOutputFilePath ( fileName : string , host : EmitHost ) {
3169+ // TODO: GH#25810 following should work but makes the build break:
3170+ // return getDeclarationEmitOutputFilePathWorker(fileName, host.getCompilerOptions(), host.getCurrentDirectory(), host.getCommonSourceDirectory(), f => host.getCanonicalFileName(f));
3171+
31693172 const options = host . getCompilerOptions ( ) ;
31703173 const outputDir = options . declarationDir || options . outDir ; // Prefer declaration folder if specified
31713174
31723175 const path = outputDir
3173- ? getSourceFilePathInNewDir ( sourceFile , host , outputDir )
3174- : sourceFile . fileName ;
3176+ ? getSourceFilePathInNewDir ( fileName , host , outputDir )
3177+ : fileName ;
3178+ return removeFileExtension ( path ) + Extension . Dts ;
3179+ }
3180+
3181+ export function getDeclarationEmitOutputFilePathWorker ( fileName : string , options : CompilerOptions , currentDirectory : string , commonSourceDirectory : string , getCanonicalFileName : GetCanonicalFileName ) : string {
3182+ const outputDir = options . declarationDir || options . outDir ; // Prefer declaration folder if specified
3183+
3184+ const path = outputDir
3185+ ? getSourceFilePathInNewDirWorker ( fileName , outputDir , currentDirectory , commonSourceDirectory , getCanonicalFileName )
3186+ : fileName ;
31753187 return removeFileExtension ( path ) + Extension . Dts ;
31763188 }
31773189
@@ -3213,10 +3225,13 @@ namespace ts {
32133225 return ! ( options . noEmitForJsFiles && isSourceFileJavaScript ( sourceFile ) ) && ! sourceFile . isDeclarationFile && ! isSourceFileFromExternalLibrary ( sourceFile ) ;
32143226 }
32153227
3216- export function getSourceFilePathInNewDir ( sourceFile : SourceFile , host : EmitHost , newDirPath : string ) {
3217- let sourceFilePath = getNormalizedAbsolutePath ( sourceFile . fileName , host . getCurrentDirectory ( ) ) ;
3218- const commonSourceDirectory = host . getCommonSourceDirectory ( ) ;
3219- const isSourceFileInCommonSourceDirectory = host . getCanonicalFileName ( sourceFilePath ) . indexOf ( host . getCanonicalFileName ( commonSourceDirectory ) ) === 0 ;
3228+ export function getSourceFilePathInNewDir ( fileName : string , host : EmitHost , newDirPath : string ) : string {
3229+ return getSourceFilePathInNewDirWorker ( fileName , newDirPath , host . getCurrentDirectory ( ) , host . getCommonSourceDirectory ( ) , f => host . getCanonicalFileName ( f ) ) ;
3230+ }
3231+
3232+ export function getSourceFilePathInNewDirWorker ( fileName : string , newDirPath : string , currentDirectory : string , commonSourceDirectory : string , getCanonicalFileName : GetCanonicalFileName ) : string {
3233+ let sourceFilePath = getNormalizedAbsolutePath ( fileName , currentDirectory ) ;
3234+ const isSourceFileInCommonSourceDirectory = getCanonicalFileName ( sourceFilePath ) . indexOf ( getCanonicalFileName ( commonSourceDirectory ) ) === 0 ;
32203235 sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath . substring ( commonSourceDirectory . length ) : sourceFilePath ;
32213236 return combinePaths ( newDirPath , sourceFilePath ) ;
32223237 }
0 commit comments