@@ -20,7 +20,7 @@ namespace ts {
20
20
export function forEachEmittedFile < T > (
21
21
host : EmitHost , action : ( emitFileNames : EmitFileNames , sourceFileOrBundle : SourceFile | Bundle | undefined ) => T ,
22
22
sourceFilesOrTargetSourceFile ?: ReadonlyArray < SourceFile > | SourceFile ,
23
- emitOnlyDtsFiles = false ,
23
+ forceDtsEmit = false ,
24
24
onlyBuildInfo ?: boolean ,
25
25
includeBuildInfo ?: boolean ) {
26
26
const sourceFiles = isArray ( sourceFilesOrTargetSourceFile ) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit ( host , sourceFilesOrTargetSourceFile ) ;
@@ -29,7 +29,7 @@ namespace ts {
29
29
const prepends = host . getPrependNodes ( ) ;
30
30
if ( sourceFiles . length || prepends . length ) {
31
31
const bundle = createBundle ( sourceFiles , prepends ) ;
32
- const result = action ( getOutputPathsFor ( bundle , host , emitOnlyDtsFiles ) , bundle ) ;
32
+ const result = action ( getOutputPathsFor ( bundle , host , forceDtsEmit ) , bundle ) ;
33
33
if ( result ) {
34
34
return result ;
35
35
}
@@ -38,7 +38,7 @@ namespace ts {
38
38
else {
39
39
if ( ! onlyBuildInfo ) {
40
40
for ( const sourceFile of sourceFiles ) {
41
- const result = action ( getOutputPathsFor ( sourceFile , host , emitOnlyDtsFiles ) , sourceFile ) ;
41
+ const result = action ( getOutputPathsFor ( sourceFile , host , forceDtsEmit ) , sourceFile ) ;
42
42
if ( result ) {
43
43
return result ;
44
44
}
@@ -227,7 +227,7 @@ namespace ts {
227
227
228
228
/*@internal */
229
229
// 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 {
231
231
const compilerOptions = host . getCompilerOptions ( ) ;
232
232
const sourceMapDataList : SourceMapEmitResult [ ] | undefined = ( compilerOptions . sourceMap || compilerOptions . inlineSourceMap || getAreDeclarationMapsEnabled ( compilerOptions ) ) ? [ ] : undefined ;
233
233
const emittedFilesList : string [ ] | undefined = compilerOptions . listEmittedFiles ? [ ] : undefined ;
@@ -241,7 +241,14 @@ namespace ts {
241
241
242
242
// Emit each output file
243
243
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
+ ) ;
245
252
exit ( ) ;
246
253
247
254
@@ -400,7 +407,7 @@ namespace ts {
400
407
} ) ;
401
408
const declBlocked = ( ! ! declarationTransform . diagnostics && ! ! declarationTransform . diagnostics . length ) || ! ! host . isEmitBlocked ( declarationFilePath ) || ! ! compilerOptions . noEmit ;
402
409
emitSkipped = emitSkipped || declBlocked ;
403
- if ( ! declBlocked || emitOnlyDtsFiles ) {
410
+ if ( ! declBlocked || forceDtsEmit ) {
404
411
Debug . assert ( declarationTransform . transformed . length === 1 , "Should only see one output from the decl transform" ) ;
405
412
printSourceFileOrBundle (
406
413
declarationFilePath ,
@@ -415,7 +422,7 @@ namespace ts {
415
422
// Explicitly do not passthru either `inline` option
416
423
}
417
424
) ;
418
- if ( emitOnlyDtsFiles && declarationTransform . transformed [ 0 ] . kind === SyntaxKind . SourceFile ) {
425
+ if ( forceDtsEmit && declarationTransform . transformed [ 0 ] . kind === SyntaxKind . SourceFile ) {
419
426
const sourceFile = declarationTransform . transformed [ 0 ] ;
420
427
exportedModulesFromDeclarationEmit = sourceFile . exportedModulesFromDeclarationEmit ;
421
428
}
0 commit comments