@@ -406,14 +406,13 @@ namespace ts {
406
406
}
407
407
408
408
/**
409
- * Handles sematic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
409
+ * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
410
410
* This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
411
- * Similar to cleanSemanticDiagnosticsOfAffectedFile
412
411
*/
413
412
function handleDtsMayChangeOfAffectedFile ( state : BuilderProgramState , affectedFile : SourceFile , cancellationToken : CancellationToken | undefined , computeHash : BuilderState . ComputeHash ) {
414
413
removeSemanticDiagnosticsOf ( state , affectedFile . path ) ;
415
414
416
- // If affected files is everything except default librarry , then nothing more to do
415
+ // If affected files is everything except default library , then nothing more to do
417
416
if ( state . allFilesExcludingDefaultLibraryFile === state . affectedFiles ) {
418
417
if ( ! state . cleanedDiagnosticsOfLibFiles ) {
419
418
state . cleanedDiagnosticsOfLibFiles = true ;
@@ -442,7 +441,19 @@ namespace ts {
442
441
const program = Debug . assertDefined ( state . program ) ;
443
442
const sourceFile = program . getSourceFileByPath ( path ) ;
444
443
if ( sourceFile ) {
445
- BuilderState . updateShapeSignature ( state , program , sourceFile , Debug . assertDefined ( state . currentAffectedFilesSignatures ) , cancellationToken , computeHash , state . currentAffectedFilesExportedModulesMap ) ;
444
+ // Even though the js emit doesnt change and we are already handling dts emit and semantic diagnostics
445
+ // we need to update the signature to reflect correctness of the signature(which is output d.ts emit) of this file
446
+ // This ensures that we dont later during incremental builds considering wrong signature.
447
+ // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
448
+ BuilderState . updateShapeSignature (
449
+ state ,
450
+ program ,
451
+ sourceFile ,
452
+ Debug . assertDefined ( state . currentAffectedFilesSignatures ) ,
453
+ cancellationToken ,
454
+ computeHash ,
455
+ state . currentAffectedFilesExportedModulesMap
456
+ ) ;
446
457
// If not dts emit, nothing more to do
447
458
if ( getEmitDeclarations ( state . compilerOptions ) ) {
448
459
addToAffectedFilesPendingEmit ( state , [ path ] ) ;
0 commit comments