@@ -340,7 +340,7 @@ namespace ts {
340
340
// Set the next affected file as seen and remove the cached semantic diagnostics
341
341
state . affectedFilesIndex = affectedFilesIndex ;
342
342
cleanSemanticDiagnosticsOfAffectedFile ( state , affectedFile ) ;
343
- handleDtsMayChangeOfAffectedFile ( state , affectedFile )
343
+ handleDtsMayChangeOfAffectedFile ( state , affectedFile , cancellationToken , computeHash ) ;
344
344
return affectedFile ;
345
345
}
346
346
seenAffectedFiles . set ( affectedFile . path , true ) ;
@@ -451,11 +451,7 @@ namespace ts {
451
451
* Add files, that are referencing modules that export entities from affected file as pending emit since dts may change
452
452
* Similar to cleanSemanticDiagnosticsOfAffectedFile
453
453
*/
454
- function handleDtsMayChangeOfAffectedFile ( state : BuilderProgramState , affectedFile : SourceFile ) {
455
- // If not dts emit, nothing more to do
456
- if ( ! getEmitDeclarations ( state . compilerOptions ) ) {
457
- return ;
458
- }
454
+ function handleDtsMayChangeOfAffectedFile ( state : BuilderProgramState , affectedFile : SourceFile , cancellationToken : CancellationToken | undefined , computeHash : BuilderState . ComputeHash ) {
459
455
460
456
// If affected files is everything except default librarry, then nothing more to do
461
457
if ( state . allFilesExcludingDefaultLibraryFile === state . affectedFiles ) {
@@ -468,10 +464,26 @@ namespace ts {
468
464
return ;
469
465
}
470
466
471
- forEachReferencingModulesOfExportOfAffectedFile ( state , affectedFile , ( state , filePath ) => {
472
- addToAffectedFilesPendingEmit ( state , [ filePath ] ) ;
473
- return false ;
474
- } ) ;
467
+ forEachReferencingModulesOfExportOfAffectedFile ( state , affectedFile , ( state , path ) => handleDtsMayChangeOf ( state , path , cancellationToken , computeHash ) ) ;
468
+ }
469
+
470
+ /**
471
+ * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
472
+ * Also we need to make sure signature is updated for these files
473
+ */
474
+ function handleDtsMayChangeOf ( state : BuilderProgramState , path : Path , cancellationToken : CancellationToken | undefined , computeHash : BuilderState . ComputeHash ) {
475
+ if ( ! state . changedFilesSet . has ( path ) ) {
476
+ const program = Debug . assertDefined ( state . program ) ;
477
+ const sourceFile = program . getSourceFileByPath ( path ) ;
478
+ if ( sourceFile ) {
479
+ BuilderState . updateShapeSignature ( state , program , sourceFile , Debug . assertDefined ( state . currentAffectedFilesSignatures ) , cancellationToken , computeHash , state . currentAffectedFilesExportedModulesMap ) ;
480
+ // If not dts emit, nothing more to do
481
+ if ( getEmitDeclarations ( state . compilerOptions ) ) {
482
+ addToAffectedFilesPendingEmit ( state , [ path ] ) ;
483
+ }
484
+ }
485
+ }
486
+ return false ;
475
487
}
476
488
477
489
/**
0 commit comments