@@ -491,8 +491,6 @@ namespace ts {
491
491
}
492
492
}
493
493
}
494
-
495
- return false ;
496
494
}
497
495
498
496
/**
@@ -517,7 +515,7 @@ namespace ts {
517
515
/**
518
516
* Iterate on referencing modules that export entities from affected file
519
517
*/
520
- function forEachReferencingModulesOfExportOfAffectedFile ( state : BuilderProgramState , affectedFile : SourceFile , fn : ( state : BuilderProgramState , filePath : Path ) => boolean ) {
518
+ function forEachReferencingModulesOfExportOfAffectedFile ( state : BuilderProgramState , affectedFile : SourceFile , fn : ( state : BuilderProgramState , filePath : Path ) => void ) {
521
519
// If there was change in signature (dts output) for the changed file,
522
520
// then only we need to handle pending file emit
523
521
if ( ! state . exportedModulesMap || ! state . changedFilesSet . has ( affectedFile . resolvedPath ) ) {
@@ -536,8 +534,8 @@ namespace ts {
536
534
const currentPath = queue . pop ( ) ! ;
537
535
if ( ! seenFileNamesMap . has ( currentPath ) ) {
538
536
seenFileNamesMap . set ( currentPath , true ) ;
539
- const result = fn ( state , currentPath ) ;
540
- if ( result && isChangedSignature ( state , currentPath ) ) {
537
+ fn ( state , currentPath ) ;
538
+ if ( isChangedSignature ( state , currentPath ) ) {
541
539
const currentSourceFile = Debug . checkDefined ( state . program ) . getSourceFileByPath ( currentPath ) ! ;
542
540
queue . push ( ...BuilderState . getReferencedByPaths ( state , currentSourceFile . resolvedPath ) ) ;
543
541
}
@@ -549,13 +547,11 @@ namespace ts {
549
547
const seenFileAndExportsOfFile = new Set < string > ( ) ;
550
548
// Go through exported modules from cache first
551
549
// If exported modules has path, all files referencing file exported from are affected
552
- if ( forEachEntry ( state . currentAffectedFilesExportedModulesMap , ( exportedModules , exportedFromPath ) =>
550
+ forEachEntry ( state . currentAffectedFilesExportedModulesMap , ( exportedModules , exportedFromPath ) =>
553
551
exportedModules &&
554
552
exportedModules . has ( affectedFile . resolvedPath ) &&
555
553
forEachFilesReferencingPath ( state , exportedFromPath , seenFileAndExportsOfFile , fn )
556
- ) ) {
557
- return ;
558
- }
554
+ ) ;
559
555
560
556
// If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
561
557
forEachEntry ( state . exportedModulesMap , ( exportedModules , exportedFromPath ) =>
@@ -568,47 +564,41 @@ namespace ts {
568
564
/**
569
565
* Iterate on files referencing referencedPath
570
566
*/
571
- function forEachFilesReferencingPath ( state : BuilderProgramState , referencedPath : Path , seenFileAndExportsOfFile : Set < string > , fn : ( state : BuilderProgramState , filePath : Path ) => boolean ) {
572
- return forEachEntry ( state . referencedMap ! , ( referencesInFile , filePath ) =>
567
+ function forEachFilesReferencingPath ( state : BuilderProgramState , referencedPath : Path , seenFileAndExportsOfFile : Set < string > , fn : ( state : BuilderProgramState , filePath : Path ) => void ) {
568
+ forEachEntry ( state . referencedMap ! , ( referencesInFile , filePath ) =>
573
569
referencesInFile . has ( referencedPath ) && forEachFileAndExportsOfFile ( state , filePath , seenFileAndExportsOfFile , fn )
574
570
) ;
575
571
}
576
572
577
573
/**
578
574
* fn on file and iterate on anything that exports this file
579
575
*/
580
- function forEachFileAndExportsOfFile ( state : BuilderProgramState , filePath : Path , seenFileAndExportsOfFile : Set < string > , fn : ( state : BuilderProgramState , filePath : Path ) => boolean ) : boolean {
576
+ function forEachFileAndExportsOfFile ( state : BuilderProgramState , filePath : Path , seenFileAndExportsOfFile : Set < string > , fn : ( state : BuilderProgramState , filePath : Path ) => void ) {
581
577
if ( ! tryAddToSet ( seenFileAndExportsOfFile , filePath ) ) {
582
- return false ;
578
+ return ;
583
579
}
584
580
585
- if ( fn ( state , filePath ) ) {
586
- // If there are no more diagnostics from old cache, done
587
- return true ;
588
- }
581
+ fn ( state , filePath ) ;
589
582
590
583
Debug . assert ( ! ! state . currentAffectedFilesExportedModulesMap ) ;
591
584
// Go through exported modules from cache first
592
585
// If exported modules has path, all files referencing file exported from are affected
593
- if ( forEachEntry ( state . currentAffectedFilesExportedModulesMap , ( exportedModules , exportedFromPath ) =>
586
+ forEachEntry ( state . currentAffectedFilesExportedModulesMap , ( exportedModules , exportedFromPath ) =>
594
587
exportedModules &&
595
588
exportedModules . has ( filePath ) &&
596
589
forEachFileAndExportsOfFile ( state , exportedFromPath , seenFileAndExportsOfFile , fn )
597
- ) ) {
598
- return true ;
599
- }
590
+ ) ;
600
591
601
592
// If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
602
- if ( forEachEntry ( state . exportedModulesMap ! , ( exportedModules , exportedFromPath ) =>
593
+ forEachEntry ( state . exportedModulesMap ! , ( exportedModules , exportedFromPath ) =>
603
594
! state . currentAffectedFilesExportedModulesMap ! . has ( exportedFromPath ) && // If we already iterated this through cache, ignore it
604
595
exportedModules . has ( filePath ) &&
605
596
forEachFileAndExportsOfFile ( state , exportedFromPath , seenFileAndExportsOfFile , fn )
606
- ) ) {
607
- return true ;
608
- }
597
+ ) ;
609
598
610
599
// Remove diagnostics of files that import this file (without going to exports of referencing files)
611
- return ! ! forEachEntry ( state . referencedMap ! , ( referencesInFile , referencingFilePath ) =>
600
+
601
+ forEachEntry ( state . referencedMap ! , ( referencesInFile , referencingFilePath ) =>
612
602
referencesInFile . has ( filePath ) &&
613
603
! seenFileAndExportsOfFile . has ( referencingFilePath ) && // Not already removed diagnostic file
614
604
fn ( state , referencingFilePath ) // Dont add to seen since this is not yet done with the export removal
0 commit comments