@@ -18,8 +18,8 @@ namespace ts {
1818 * If an array, the full list of source files to emit.
1919 * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit.
2020 */
21- export function forEachEmittedFile (
22- host : EmitHost , action : ( emitFileNames : EmitFileNames , sourceFileOrBundle : SourceFile | Bundle , emitOnlyDtsFiles : boolean ) => void ,
21+ export function forEachEmittedFile < T > (
22+ host : EmitHost , action : ( emitFileNames : EmitFileNames , sourceFileOrBundle : SourceFile | Bundle , emitOnlyDtsFiles : boolean ) => T ,
2323 sourceFilesOrTargetSourceFile ?: SourceFile [ ] | SourceFile ,
2424 emitOnlyDtsFiles ?: boolean ) {
2525
@@ -30,15 +30,21 @@ namespace ts {
3030 const jsFilePath = options . outFile || options . out ;
3131 const sourceMapFilePath = getSourceMapFilePath ( jsFilePath , options ) ;
3232 const declarationFilePath = options . declaration ? removeFileExtension ( jsFilePath ) + Extension . Dts : "" ;
33- action ( { jsFilePath, sourceMapFilePath, declarationFilePath } , createBundle ( sourceFiles ) , emitOnlyDtsFiles ) ;
33+ const result = action ( { jsFilePath, sourceMapFilePath, declarationFilePath } , createBundle ( sourceFiles ) , emitOnlyDtsFiles ) ;
34+ if ( result ) {
35+ return result ;
36+ }
3437 }
3538 }
3639 else {
3740 for ( const sourceFile of sourceFiles ) {
3841 const jsFilePath = getOwnEmitOutputFilePath ( sourceFile , host , getOutputExtension ( sourceFile , options ) ) ;
3942 const sourceMapFilePath = getSourceMapFilePath ( jsFilePath , options ) ;
4043 const declarationFilePath = ! isSourceFileJavaScript ( sourceFile ) && ( emitOnlyDtsFiles || options . declaration ) ? getDeclarationEmitOutputFilePath ( sourceFile , host ) : undefined ;
41- action ( { jsFilePath, sourceMapFilePath, declarationFilePath } , sourceFile , emitOnlyDtsFiles ) ;
44+ const result = action ( { jsFilePath, sourceMapFilePath, declarationFilePath } , sourceFile , emitOnlyDtsFiles ) ;
45+ if ( result ) {
46+ return result ;
47+ }
4248 }
4349 }
4450 }
0 commit comments