@@ -583,35 +583,50 @@ export function getOutputExtension(fileName: string, options: CompilerOptions):
583583 Extension . Js ;
584584}
585585
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 {
587592 return outputDir ?
588593 resolvePath (
589594 outputDir ,
590- getRelativePathFromDirectory ( getCommonSourceDirectory ? getCommonSourceDirectory ( ) : getCommonSourceDirectoryOfConfig ( configFile , ignoreCase ) , inputFileName , ignoreCase ) ,
595+ getRelativePathFromDirectory ( getCommonSourceDirectory ( ) , inputFileName , ignoreCase ) ,
591596 ) :
592597 inputFileName ;
593598}
594599
595600/** @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 ) {
597607 return changeExtension (
598- getOutputPathWithoutChangingExt ( inputFileName , configFile , ignoreCase , configFile . options . declarationDir || configFile . options . outDir , getCommonSourceDirectory ) ,
608+ getOutputPathWithoutChangingExt ( inputFileName , ignoreCase , options . declarationDir || options . outDir , getCommonSourceDirectory ) ,
599609 getDeclarationEmitExtensionForPath ( inputFileName ) ,
600610 ) ;
601611}
602612
603- function getOutputJSFileName ( inputFileName : string , configFile : ParsedCommandLine , ignoreCase : boolean , getCommonSourceDirectory ?: ( ) => string ) {
613+ function getOutputJSFileName ( inputFileName : string , configFile : ParsedCommandLine , ignoreCase : boolean , getCommonSourceDirectory = ( ) => getCommonSourceDirectoryOfConfig ( configFile , ignoreCase ) ) {
604614 if ( configFile . options . emitDeclarationOnly ) return undefined ;
605615 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 ) ;
610617 return ! isJsonFile || comparePaths ( inputFileName , outputFileName , Debug . checkDefined ( configFile . options . configFilePath ) , ignoreCase ) !== Comparison . EqualTo ?
611618 outputFileName :
612619 undefined ;
613620}
614621
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+
615630function createAddOutput ( ) {
616631 let outputs : string [ ] | undefined ;
617632 return { addOutput, getOutputs } ;
0 commit comments