@@ -135,36 +135,34 @@ namespace ts {
135
135
return configFile . options . rootDir || getDirectoryPath ( Debug . assertDefined ( configFile . options . configFilePath ) ) ;
136
136
}
137
137
138
+ function getOutputPathWithoutChangingExt ( inputFileName : string , configFile : ParsedCommandLine , ignoreCase : boolean , outputDir : string | undefined ) {
139
+ return outputDir ?
140
+ resolvePath (
141
+ outputDir ,
142
+ getRelativePathFromDirectory ( rootDirOfOptions ( configFile ) , inputFileName , ignoreCase )
143
+ ) :
144
+ inputFileName ;
145
+ }
146
+
138
147
/* @internal */
139
148
export function getOutputDeclarationFileName ( inputFileName : string , configFile : ParsedCommandLine , ignoreCase : boolean ) {
140
149
Debug . assert ( ! fileExtensionIs ( inputFileName , Extension . Dts ) && hasTSFileExtension ( inputFileName ) ) ;
141
- let outputPath : string ;
142
- const declarationDir = configFile . options . declarationDir || configFile . options . outDir ;
143
- if ( declarationDir ) {
144
- const relativePath = getRelativePathFromDirectory ( rootDirOfOptions ( configFile ) , inputFileName , ignoreCase ) ;
145
- outputPath = resolvePath ( declarationDir , relativePath ) ;
146
- }
147
- else {
148
- outputPath = inputFileName ;
149
- }
150
- return changeExtension ( outputPath , Extension . Dts ) ;
150
+ return changeExtension (
151
+ getOutputPathWithoutChangingExt ( inputFileName , configFile , ignoreCase , configFile . options . declarationDir || configFile . options . outDir ) ,
152
+ Extension . Dts
153
+ ) ;
151
154
}
152
155
153
156
function getOutputJSFileName ( inputFileName : string , configFile : ParsedCommandLine , ignoreCase : boolean ) {
154
- let outputPath : string ;
155
- if ( configFile . options . outDir ) {
156
- const relativePath = getRelativePathFromDirectory ( rootDirOfOptions ( configFile ) , inputFileName , ignoreCase ) ;
157
- outputPath = resolvePath ( configFile . options . outDir , relativePath ) ;
158
- }
159
- else {
160
- outputPath = inputFileName ;
161
- }
162
157
const isJsonFile = fileExtensionIs ( inputFileName , Extension . Json ) ;
163
- const outputFileName = changeExtension ( outputPath , isJsonFile ?
164
- Extension . Json :
165
- fileExtensionIs ( inputFileName , Extension . Tsx ) && configFile . options . jsx === JsxEmit . Preserve ?
166
- Extension . Jsx :
167
- Extension . Js ) ;
158
+ const outputFileName = changeExtension (
159
+ getOutputPathWithoutChangingExt ( inputFileName , configFile , ignoreCase , configFile . options . outDir ) ,
160
+ isJsonFile ?
161
+ Extension . Json :
162
+ fileExtensionIs ( inputFileName , Extension . Tsx ) && configFile . options . jsx === JsxEmit . Preserve ?
163
+ Extension . Jsx :
164
+ Extension . Js
165
+ ) ;
168
166
return ! isJsonFile || comparePaths ( inputFileName , outputFileName , Debug . assertDefined ( configFile . options . configFilePath ) , ignoreCase ) !== Comparison . EqualTo ?
169
167
outputFileName :
170
168
undefined ;
0 commit comments