@@ -20,7 +20,7 @@ namespace ts {
2020 export function forEachEmittedFile < T > (
2121 host : EmitHost , action : ( emitFileNames : EmitFileNames , sourceFileOrBundle : SourceFile | Bundle | undefined ) => T ,
2222 sourceFilesOrTargetSourceFile ?: ReadonlyArray < SourceFile > | SourceFile ,
23- emitOnlyDtsFiles = false ,
23+ forceDtsEmit = false ,
2424 onlyBuildInfo ?: boolean ,
2525 includeBuildInfo ?: boolean ) {
2626 const sourceFiles = isArray ( sourceFilesOrTargetSourceFile ) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit ( host , sourceFilesOrTargetSourceFile ) ;
@@ -29,7 +29,7 @@ namespace ts {
2929 const prepends = host . getPrependNodes ( ) ;
3030 if ( sourceFiles . length || prepends . length ) {
3131 const bundle = createBundle ( sourceFiles , prepends ) ;
32- const result = action ( getOutputPathsFor ( bundle , host , emitOnlyDtsFiles ) , bundle ) ;
32+ const result = action ( getOutputPathsFor ( bundle , host , forceDtsEmit ) , bundle ) ;
3333 if ( result ) {
3434 return result ;
3535 }
@@ -38,7 +38,7 @@ namespace ts {
3838 else {
3939 if ( ! onlyBuildInfo ) {
4040 for ( const sourceFile of sourceFiles ) {
41- const result = action ( getOutputPathsFor ( sourceFile , host , emitOnlyDtsFiles ) , sourceFile ) ;
41+ const result = action ( getOutputPathsFor ( sourceFile , host , forceDtsEmit ) , sourceFile ) ;
4242 if ( result ) {
4343 return result ;
4444 }
@@ -227,7 +227,7 @@ namespace ts {
227227
228228 /*@internal */
229229 // targetSourceFile is when users only want one file in entire project to be emitted. This is used in compileOnSave feature
230- export function emitFiles ( resolver : EmitResolver , host : EmitHost , targetSourceFile : SourceFile | undefined , { scriptTransformers, declarationTransformers } : EmitTransformers , emitOnlyDtsFiles ?: boolean , onlyBuildInfo ?: boolean ) : EmitResult {
230+ export function emitFiles ( resolver : EmitResolver , host : EmitHost , targetSourceFile : SourceFile | undefined , { scriptTransformers, declarationTransformers } : EmitTransformers , emitOnlyDtsFiles ?: boolean , onlyBuildInfo ?: boolean , forceDtsEmit ?: boolean ) : EmitResult {
231231 const compilerOptions = host . getCompilerOptions ( ) ;
232232 const sourceMapDataList : SourceMapEmitResult [ ] | undefined = ( compilerOptions . sourceMap || compilerOptions . inlineSourceMap || getAreDeclarationMapsEnabled ( compilerOptions ) ) ? [ ] : undefined ;
233233 const emittedFilesList : string [ ] | undefined = compilerOptions . listEmittedFiles ? [ ] : undefined ;
@@ -241,7 +241,14 @@ namespace ts {
241241
242242 // Emit each output file
243243 enter ( ) ;
244- forEachEmittedFile ( host , emitSourceFileOrBundle , getSourceFilesToEmit ( host , targetSourceFile ) , emitOnlyDtsFiles , onlyBuildInfo , ! targetSourceFile ) ;
244+ forEachEmittedFile (
245+ host ,
246+ emitSourceFileOrBundle ,
247+ getSourceFilesToEmit ( host , targetSourceFile ) ,
248+ forceDtsEmit ,
249+ onlyBuildInfo ,
250+ ! targetSourceFile
251+ ) ;
245252 exit ( ) ;
246253
247254
@@ -400,7 +407,7 @@ namespace ts {
400407 } ) ;
401408 const declBlocked = ( ! ! declarationTransform . diagnostics && ! ! declarationTransform . diagnostics . length ) || ! ! host . isEmitBlocked ( declarationFilePath ) || ! ! compilerOptions . noEmit ;
402409 emitSkipped = emitSkipped || declBlocked ;
403- if ( ! declBlocked || emitOnlyDtsFiles ) {
410+ if ( ! declBlocked || forceDtsEmit ) {
404411 Debug . assert ( declarationTransform . transformed . length === 1 , "Should only see one output from the decl transform" ) ;
405412 printSourceFileOrBundle (
406413 declarationFilePath ,
@@ -415,7 +422,7 @@ namespace ts {
415422 // Explicitly do not passthru either `inline` option
416423 }
417424 ) ;
418- if ( emitOnlyDtsFiles && declarationTransform . transformed [ 0 ] . kind === SyntaxKind . SourceFile ) {
425+ if ( forceDtsEmit && declarationTransform . transformed [ 0 ] . kind === SyntaxKind . SourceFile ) {
419426 const sourceFile = declarationTransform . transformed [ 0 ] ;
420427 exportedModulesFromDeclarationEmit = sourceFile . exportedModulesFromDeclarationEmit ;
421428 }
0 commit comments