@@ -583,35 +583,50 @@ export function getOutputExtension(fileName: string, options: CompilerOptions):
583
583
Extension . Js ;
584
584
}
585
585
586
- function getOutputPathWithoutChangingExt ( inputFileName : string , configFile : ParsedCommandLine , ignoreCase : boolean , outputDir : string | undefined , getCommonSourceDirectory ?: ( ) => string ) {
586
+ function getOutputPathWithoutChangingExt (
587
+ inputFileName : string ,
588
+ ignoreCase : boolean ,
589
+ outputDir : string | undefined ,
590
+ getCommonSourceDirectory : ( ) => string ,
591
+ ) : string {
587
592
return outputDir ?
588
593
resolvePath (
589
594
outputDir ,
590
- getRelativePathFromDirectory ( getCommonSourceDirectory ? getCommonSourceDirectory ( ) : getCommonSourceDirectoryOfConfig ( configFile , ignoreCase ) , inputFileName , ignoreCase ) ,
595
+ getRelativePathFromDirectory ( getCommonSourceDirectory ( ) , inputFileName , ignoreCase ) ,
591
596
) :
592
597
inputFileName ;
593
598
}
594
599
595
600
/** @internal */
596
- export function getOutputDeclarationFileName ( inputFileName : string , configFile : ParsedCommandLine , ignoreCase : boolean , getCommonSourceDirectory ?: ( ) => string ) {
601
+ export function getOutputDeclarationFileName ( inputFileName : string , configFile : ParsedCommandLine , ignoreCase : boolean , getCommonSourceDirectory = ( ) => getCommonSourceDirectoryOfConfig ( configFile , ignoreCase ) ) {
602
+ return getOutputDeclarationFileNameWorker ( inputFileName , configFile . options , ignoreCase , getCommonSourceDirectory ) ;
603
+ }
604
+
605
+ /** @internal */
606
+ export function getOutputDeclarationFileNameWorker ( inputFileName : string , options : CompilerOptions , ignoreCase : boolean , getCommonSourceDirectory : ( ) => string ) {
597
607
return changeExtension (
598
- getOutputPathWithoutChangingExt ( inputFileName , configFile , ignoreCase , configFile . options . declarationDir || configFile . options . outDir , getCommonSourceDirectory ) ,
608
+ getOutputPathWithoutChangingExt ( inputFileName , ignoreCase , options . declarationDir || options . outDir , getCommonSourceDirectory ) ,
599
609
getDeclarationEmitExtensionForPath ( inputFileName ) ,
600
610
) ;
601
611
}
602
612
603
- function getOutputJSFileName ( inputFileName : string , configFile : ParsedCommandLine , ignoreCase : boolean , getCommonSourceDirectory ?: ( ) => string ) {
613
+ function getOutputJSFileName ( inputFileName : string , configFile : ParsedCommandLine , ignoreCase : boolean , getCommonSourceDirectory = ( ) => getCommonSourceDirectoryOfConfig ( configFile , ignoreCase ) ) {
604
614
if ( configFile . options . emitDeclarationOnly ) return undefined ;
605
615
const isJsonFile = fileExtensionIs ( inputFileName , Extension . Json ) ;
606
- const outputFileName = changeExtension (
607
- getOutputPathWithoutChangingExt ( inputFileName , configFile , ignoreCase , configFile . options . outDir , getCommonSourceDirectory ) ,
608
- getOutputExtension ( inputFileName , configFile . options ) ,
609
- ) ;
616
+ const outputFileName = getOutputJSFileNameWorker ( inputFileName , configFile . options , ignoreCase , getCommonSourceDirectory ) ;
610
617
return ! isJsonFile || comparePaths ( inputFileName , outputFileName , Debug . checkDefined ( configFile . options . configFilePath ) , ignoreCase ) !== Comparison . EqualTo ?
611
618
outputFileName :
612
619
undefined ;
613
620
}
614
621
622
+ /** @internal */
623
+ export function getOutputJSFileNameWorker ( inputFileName : string , options : CompilerOptions , ignoreCase : boolean , getCommonSourceDirectory : ( ) => string ) : string {
624
+ return changeExtension (
625
+ getOutputPathWithoutChangingExt ( inputFileName , ignoreCase , options . outDir , getCommonSourceDirectory ) ,
626
+ getOutputExtension ( inputFileName , options ) ,
627
+ ) ;
628
+ }
629
+
615
630
function createAddOutput ( ) {
616
631
let outputs : string [ ] | undefined ;
617
632
return { addOutput, getOutputs } ;
0 commit comments