@@ -2590,27 +2590,20 @@ namespace ts {
25902590 }
25912591
25922592 /**
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.
25962594 *
25972595 * @param host An EmitHost.
25982596 * @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.
26002600 */
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 ,
26042604 emitOnlyDtsFiles ?: boolean ) {
2605- forEachEmittedFile ( host , getSourceFilesToEmit ( host , targetSourceFile ) , action , emitOnlyDtsFiles ) ;
2606- }
26072605
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 ) ;
26142607 const options = host . getCompilerOptions ( ) ;
26152608 if ( options . outFile || options . out ) {
26162609 if ( sourceFiles . length ) {
@@ -2622,7 +2615,6 @@ namespace ts {
26222615 }
26232616 else {
26242617 for ( const sourceFile of sourceFiles ) {
2625- const options = host . getCompilerOptions ( ) ;
26262618 const jsFilePath = getOwnEmitOutputFilePath ( sourceFile , host , getOutputExtension ( sourceFile , options ) ) ;
26272619 const sourceMapFilePath = getSourceMapFilePath ( jsFilePath , options ) ;
26282620 const declarationFilePath = ! isSourceFileJavaScript ( sourceFile ) && ( emitOnlyDtsFiles || options . declaration ) ? getDeclarationEmitOutputFilePath ( sourceFile , host ) : undefined ;
0 commit comments