@@ -3152,26 +3152,38 @@ namespace ts {
3152
3152
return referencePath ? ensurePathIsNonModuleName ( extensionless ) : extensionless ;
3153
3153
}
3154
3154
3155
- export function getOwnEmitOutputFilePath ( sourceFile : SourceFile , host : EmitHost , extension : string ) {
3155
+ export function getOwnEmitOutputFilePath ( fileName : string , host : EmitHost , extension : string ) {
3156
3156
const compilerOptions = host . getCompilerOptions ( ) ;
3157
3157
let emitOutputFilePathWithoutExtension : string ;
3158
3158
if ( compilerOptions . outDir ) {
3159
- emitOutputFilePathWithoutExtension = removeFileExtension ( getSourceFilePathInNewDir ( sourceFile , host , compilerOptions . outDir ) ) ;
3159
+ emitOutputFilePathWithoutExtension = removeFileExtension ( getSourceFilePathInNewDir ( fileName , host , compilerOptions . outDir ) ) ;
3160
3160
}
3161
3161
else {
3162
- emitOutputFilePathWithoutExtension = removeFileExtension ( sourceFile . fileName ) ;
3162
+ emitOutputFilePathWithoutExtension = removeFileExtension ( fileName ) ;
3163
3163
}
3164
3164
3165
3165
return emitOutputFilePathWithoutExtension + extension ;
3166
3166
}
3167
3167
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
+
3169
3172
const options = host . getCompilerOptions ( ) ;
3170
3173
const outputDir = options . declarationDir || options . outDir ; // Prefer declaration folder if specified
3171
3174
3172
3175
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 ;
3175
3187
return removeFileExtension ( path ) + Extension . Dts ;
3176
3188
}
3177
3189
@@ -3213,10 +3225,13 @@ namespace ts {
3213
3225
return ! ( options . noEmitForJsFiles && isSourceFileJavaScript ( sourceFile ) ) && ! sourceFile . isDeclarationFile && ! isSourceFileFromExternalLibrary ( sourceFile ) ;
3214
3226
}
3215
3227
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 ;
3220
3235
sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath . substring ( commonSourceDirectory . length ) : sourceFilePath ;
3221
3236
return combinePaths ( newDirPath , sourceFilePath ) ;
3222
3237
}
0 commit comments