@@ -137,7 +137,7 @@ namespace ts {
137
137
*/
138
138
emittedBuildInfo ?: boolean ;
139
139
/**
140
- * Already seen affected files
140
+ * Already seen emitted files
141
141
*/
142
142
seenEmittedFiles : Map < true > | undefined ;
143
143
/**
@@ -329,7 +329,6 @@ namespace ts {
329
329
handleDtsMayChangeOfAffectedFile ( state , affectedFile , cancellationToken , computeHash ) ;
330
330
return affectedFile ;
331
331
}
332
- seenAffectedFiles . set ( affectedFile . path , true ) ;
333
332
affectedFilesIndex ++ ;
334
333
}
335
334
@@ -549,7 +548,7 @@ namespace ts {
549
548
* This is called after completing operation on the next affected file.
550
549
* The operations here are postponed to ensure that cancellation during the iteration is handled correctly
551
550
*/
552
- function doneWithAffectedFile ( state : BuilderProgramState , affected : SourceFile | Program , isPendingEmit ?: boolean , isBuildInfoEmit ?: boolean ) {
551
+ function doneWithAffectedFile ( state : BuilderProgramState , affected : SourceFile | Program , isPendingEmit ?: boolean , isBuildInfoEmit ?: boolean , isEmitResult ?: boolean ) {
553
552
if ( isBuildInfoEmit ) {
554
553
state . emittedBuildInfo = true ;
555
554
}
@@ -559,6 +558,9 @@ namespace ts {
559
558
}
560
559
else {
561
560
state . seenAffectedFiles ! . set ( ( affected as SourceFile ) . path , true ) ;
561
+ if ( isEmitResult ) {
562
+ ( state . seenEmittedFiles || ( state . seenEmittedFiles = createMap ( ) ) ) . set ( ( affected as SourceFile ) . path , true ) ;
563
+ }
562
564
if ( isPendingEmit ) {
563
565
state . affectedFilesPendingEmitIndex ! ++ ;
564
566
}
@@ -576,6 +578,14 @@ namespace ts {
576
578
return { result, affected } ;
577
579
}
578
580
581
+ /**
582
+ * Returns the result with affected file
583
+ */
584
+ function toAffectedFileEmitResult ( state : BuilderProgramState , result : EmitResult , affected : SourceFile | Program , isPendingEmit ?: boolean , isBuildInfoEmit ?: boolean ) : AffectedFileResult < EmitResult > {
585
+ doneWithAffectedFile ( state , affected , isPendingEmit , isBuildInfoEmit , /*isEmitResult*/ true ) ;
586
+ return { result, affected } ;
587
+ }
588
+
579
589
/**
580
590
* Gets the semantic diagnostics either from cache if present, or otherwise from program and caches it
581
591
* Note that it is assumed that the when asked about semantic diagnostics, the file has been taken out of affected files/changed file set
@@ -849,7 +859,7 @@ namespace ts {
849
859
}
850
860
851
861
const affected = Debug . assertDefined ( state . program ) ;
852
- return toAffectedFileResult (
862
+ return toAffectedFileEmitResult (
853
863
state ,
854
864
// When whole program is affected, do emit only once (eg when --out or --outFile is specified)
855
865
// Otherwise just affected file
@@ -872,14 +882,14 @@ namespace ts {
872
882
}
873
883
}
874
884
875
- return toAffectedFileResult (
885
+ return toAffectedFileEmitResult (
876
886
state ,
877
887
// When whole program is affected, do emit only once (eg when --out or --outFile is specified)
878
888
// Otherwise just affected file
879
889
Debug . assertDefined ( state . program ) . emit ( affected === state . program ? undefined : affected as SourceFile , writeFile || maybeBind ( host , host . writeFile ) , cancellationToken , emitOnlyDtsFiles , customTransformers ) ,
880
890
affected ,
881
- isPendingEmitFile
882
- ) ;
891
+ isPendingEmitFile ,
892
+ ) ;
883
893
}
884
894
885
895
/**
@@ -1036,7 +1046,7 @@ namespace ts {
1036
1046
compilerOptions : convertFromReusableCompilerOptions ( program . options , toAbsolutePath ) ,
1037
1047
referencedMap : getMapOfReferencedSet ( program . referencedMap , toPath ) ,
1038
1048
exportedModulesMap : getMapOfReferencedSet ( program . exportedModulesMap , toPath ) ,
1039
- semanticDiagnosticsPerFile : program . semanticDiagnosticsPerFile && arrayToMap ( program . semanticDiagnosticsPerFile , value => isString ( value ) ? value : value [ 0 ] , value => isString ( value ) ? emptyArray : value [ 1 ] ) ,
1049
+ semanticDiagnosticsPerFile : program . semanticDiagnosticsPerFile && arrayToMap ( program . semanticDiagnosticsPerFile , value => toPath ( isString ( value ) ? value : value [ 0 ] ) , value => isString ( value ) ? emptyArray : value [ 1 ] ) ,
1040
1050
hasReusableDiagnostic : true
1041
1051
} ;
1042
1052
return {
0 commit comments