@@ -35,13 +35,15 @@ namespace ts {
35
35
forEachEmittedFile ( host , getDeclarationDiagnosticsFromFile , targetSourceFile ) ;
36
36
return declarationDiagnostics . getDiagnostics ( targetSourceFile ? targetSourceFile . fileName : undefined ) ;
37
37
38
- function getDeclarationDiagnosticsFromFile ( { declarationFilePath } : EmitFileNames , sources : SourceFile [ ] , isBundledEmit : boolean ) {
39
- emitDeclarations ( host , resolver , declarationDiagnostics , declarationFilePath , sources , isBundledEmit , /*emitOnlyDtsFiles*/ false ) ;
38
+ function getDeclarationDiagnosticsFromFile ( { declarationFilePath } : EmitFileNames , sourceFileOrBundle : SourceFile | Bundle ) {
39
+ emitDeclarations ( host , resolver , declarationDiagnostics , declarationFilePath , sourceFileOrBundle , /*emitOnlyDtsFiles*/ false ) ;
40
40
}
41
41
}
42
42
43
43
function emitDeclarations ( host : EmitHost , resolver : EmitResolver , emitterDiagnostics : DiagnosticCollection , declarationFilePath : string ,
44
- sourceFiles : SourceFile [ ] , isBundledEmit : boolean , emitOnlyDtsFiles : boolean ) : DeclarationEmit {
44
+ sourceFileOrBundle : SourceFile | Bundle , emitOnlyDtsFiles : boolean ) : DeclarationEmit {
45
+ const sourceFiles = sourceFileOrBundle . kind === SyntaxKind . Bundle ? sourceFileOrBundle . sourceFiles : [ sourceFileOrBundle ] ;
46
+ const isBundledEmit = sourceFileOrBundle . kind === SyntaxKind . Bundle ;
45
47
const newLine = host . getNewLine ( ) ;
46
48
const compilerOptions = host . getCompilerOptions ( ) ;
47
49
@@ -1803,8 +1805,9 @@ namespace ts {
1803
1805
}
1804
1806
return addedBundledEmitReference ;
1805
1807
1806
- function getDeclFileName ( emitFileNames : EmitFileNames , _sourceFiles : SourceFile [ ] , isBundledEmit : boolean ) {
1808
+ function getDeclFileName ( emitFileNames : EmitFileNames , sourceFileOrBundle : SourceFile | Bundle ) {
1807
1809
// Dont add reference path to this file if it is a bundled emit and caller asked not emit bundled file path
1810
+ const isBundledEmit = sourceFileOrBundle . kind === SyntaxKind . Bundle ;
1808
1811
if ( isBundledEmit && ! addBundledFileReference ) {
1809
1812
return ;
1810
1813
}
@@ -1817,10 +1820,11 @@ namespace ts {
1817
1820
}
1818
1821
1819
1822
/* @internal */
1820
- export function writeDeclarationFile ( declarationFilePath : string , sourceFiles : SourceFile [ ] , isBundledEmit : boolean , host : EmitHost , resolver : EmitResolver , emitterDiagnostics : DiagnosticCollection , emitOnlyDtsFiles : boolean ) {
1821
- const emitDeclarationResult = emitDeclarations ( host , resolver , emitterDiagnostics , declarationFilePath , sourceFiles , isBundledEmit , emitOnlyDtsFiles ) ;
1823
+ export function writeDeclarationFile ( declarationFilePath : string , sourceFileOrBundle : SourceFile | Bundle , host : EmitHost , resolver : EmitResolver , emitterDiagnostics : DiagnosticCollection , emitOnlyDtsFiles : boolean ) {
1824
+ const emitDeclarationResult = emitDeclarations ( host , resolver , emitterDiagnostics , declarationFilePath , sourceFileOrBundle , emitOnlyDtsFiles ) ;
1822
1825
const emitSkipped = emitDeclarationResult . reportedDeclarationError || host . isEmitBlocked ( declarationFilePath ) || host . getCompilerOptions ( ) . noEmit ;
1823
1826
if ( ! emitSkipped ) {
1827
+ const sourceFiles = sourceFileOrBundle . kind === SyntaxKind . Bundle ? sourceFileOrBundle . sourceFiles : [ sourceFileOrBundle ] ;
1824
1828
const declarationOutput = emitDeclarationResult . referencesOutput
1825
1829
+ getDeclarationOutput ( emitDeclarationResult . synchronousDeclarationOutput , emitDeclarationResult . moduleElementDeclarationEmitInfo ) ;
1826
1830
writeFile ( host , emitterDiagnostics , declarationFilePath , declarationOutput , host . getCompilerOptions ( ) . emitBOM , sourceFiles ) ;
0 commit comments