@@ -2590,27 +2590,20 @@ namespace ts {
2590
2590
}
2591
2591
2592
2592
/**
2593
- * Iterates over the source files that are expected to have an emit output. This function
2594
- * is used by the legacy emitter and the declaration emitter and should not be used by
2595
- * the tree transforming emitter.
2593
+ * Iterates over the source files that are expected to have an emit output.
2596
2594
*
2597
2595
* @param host An EmitHost.
2598
2596
* @param action The action to execute.
2599
- * @param targetSourceFile An optional target source file to emit.
2597
+ * @param sourceFilesOrTargetSourceFile
2598
+ * If an array, the full list of source files to emit.
2599
+ * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit.
2600
2600
*/
2601
- export function forEachExpectedEmitFile ( host : EmitHost ,
2602
- action : ( emitFileNames : EmitFileNames , sourceFiles : SourceFile [ ] , isBundledEmit : boolean , emitOnlyDtsFiles : boolean ) => void ,
2603
- targetSourceFile ?: SourceFile ,
2601
+ export function forEachEmittedFile (
2602
+ host : EmitHost , action : ( emitFileNames : EmitFileNames , sourceFiles : SourceFile [ ] , isBundledEmit : boolean , emitOnlyDtsFiles : boolean ) => void ,
2603
+ sourceFilesOrTargetSourceFile ?: SourceFile [ ] | SourceFile ,
2604
2604
emitOnlyDtsFiles ?: boolean ) {
2605
- forEachEmittedFile ( host , getSourceFilesToEmit ( host , targetSourceFile ) , action , emitOnlyDtsFiles ) ;
2606
- }
2607
2605
2608
- /**
2609
- * Iterates over each source file to emit.
2610
- */
2611
- export function forEachEmittedFile ( host : EmitHost , sourceFiles : SourceFile [ ] ,
2612
- action : ( emitFileNames : EmitFileNames , sourceFiles : SourceFile [ ] , isBundledEmit : boolean , emitOnlyDtsFiles : boolean ) => void ,
2613
- emitOnlyDtsFiles ?: boolean ) {
2606
+ const sourceFiles = isArray ( sourceFilesOrTargetSourceFile ) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit ( host , sourceFilesOrTargetSourceFile ) ;
2614
2607
const options = host . getCompilerOptions ( ) ;
2615
2608
if ( options . outFile || options . out ) {
2616
2609
if ( sourceFiles . length ) {
@@ -2622,7 +2615,6 @@ namespace ts {
2622
2615
}
2623
2616
else {
2624
2617
for ( const sourceFile of sourceFiles ) {
2625
- const options = host . getCompilerOptions ( ) ;
2626
2618
const jsFilePath = getOwnEmitOutputFilePath ( sourceFile , host , getOutputExtension ( sourceFile , options ) ) ;
2627
2619
const sourceMapFilePath = getSourceMapFilePath ( jsFilePath , options ) ;
2628
2620
const declarationFilePath = ! isSourceFileJavaScript ( sourceFile ) && ( emitOnlyDtsFiles || options . declaration ) ? getDeclarationEmitOutputFilePath ( sourceFile , host ) : undefined ;
0 commit comments