@@ -980,24 +980,21 @@ namespace ts {
980
980
981
981
// Actual Emit
982
982
const { host, compilerHost } = state ;
983
- let resultFlags = BuildResultFlags . DeclarationOutputUnchanged ;
984
- const existingBuildInfo = state . buildInfoCache . get ( projectPath ) ?. buildInfo || undefined ;
983
+ const hasChangedEmitSignature = program . hasChangedEmitSignature ?. ( ) ;
984
+ let resultFlags = hasChangedEmitSignature ? BuildResultFlags . None : BuildResultFlags . DeclarationOutputUnchanged ;
985
985
const emitterDiagnostics = createDiagnosticCollection ( ) ;
986
986
const emittedOutputs = new Map < Path , string > ( ) ;
987
987
const options = program . getCompilerOptions ( ) ;
988
988
const isIncremental = isIncrementalCompilation ( options ) ;
989
989
let outputTimeStampMap : ESMap < Path , Date > | undefined ;
990
990
let now : Date | undefined ;
991
+ // Check dts write only if hasChangedEmitSignature is not implemented
992
+ const checkDtsChange = options . composite && hasChangedEmitSignature === undefined ;
991
993
outputFiles . forEach ( ( { name, text, writeByteOrderMark, buildInfo } ) => {
992
994
const path = toPath ( state , name ) ;
993
995
emittedOutputs . set ( toPath ( state , name ) , name ) ;
994
- if ( buildInfo ) {
995
- setBuildInfo ( state , buildInfo , projectPath , options ) ;
996
- // Buildinfo has information on when last dts change time
997
- if ( buildInfo . program ?. dtsChangeTime !== existingBuildInfo ?. program ?. dtsChangeTime ) {
998
- resultFlags &= ~ BuildResultFlags . DeclarationOutputUnchanged ;
999
- }
1000
- }
996
+ if ( checkDtsChange && isDeclarationFileName ( name ) ) resultFlags &= ~ BuildResultFlags . DeclarationOutputUnchanged ;
997
+ if ( buildInfo ) setBuildInfo ( state , buildInfo , projectPath , options ) ;
1001
998
writeFile ( writeFileCallback ? { writeFile : writeFileCallback } : compilerHost , emitterDiagnostics , name , text , writeByteOrderMark ) ;
1002
999
if ( ! isIncremental && state . watch ) {
1003
1000
( outputTimeStampMap ||= getOutputTimeStampMap ( state , projectPath ) ! ) . set ( path , now ||= getCurrentTime ( state . host ) ) ;
@@ -1116,15 +1113,10 @@ namespace ts {
1116
1113
const emitterDiagnostics = createDiagnosticCollection ( ) ;
1117
1114
const emittedOutputs = new Map < Path , string > ( ) ;
1118
1115
let resultFlags = BuildResultFlags . DeclarationOutputUnchanged ;
1119
- const existingBuildInfo = state . buildInfoCache . get ( projectPath ) ! . buildInfo as BuildInfo ;
1120
1116
outputFiles . forEach ( ( { name, text, writeByteOrderMark, buildInfo } ) => {
1121
1117
emittedOutputs . set ( toPath ( state , name ) , name ) ;
1122
- if ( buildInfo ) {
1123
- setBuildInfo ( state , buildInfo , projectPath , config . options ) ;
1124
- if ( buildInfo . program ?. dtsChangeTime !== existingBuildInfo . program ?. dtsChangeTime ) {
1125
- resultFlags &= ~ BuildResultFlags . DeclarationOutputUnchanged ;
1126
- }
1127
- }
1118
+ if ( isDeclarationFileName ( name ) ) resultFlags &= ~ BuildResultFlags . DeclarationOutputUnchanged ;
1119
+ if ( buildInfo ) setBuildInfo ( state , buildInfo , projectPath , config . options ) ;
1128
1120
writeFile ( writeFileCallback ? { writeFile : writeFileCallback } : compilerHost , emitterDiagnostics , name , text , writeByteOrderMark ) ;
1129
1121
} ) ;
1130
1122
0 commit comments