@@ -137,7 +137,7 @@ namespace ts {
137137 */
138138 emittedBuildInfo ?: boolean ;
139139 /**
140- * Already seen affected files
140+ * Already seen emitted files
141141 */
142142 seenEmittedFiles : Map < true > | undefined ;
143143 /**
@@ -329,7 +329,6 @@ namespace ts {
329329 handleDtsMayChangeOfAffectedFile ( state , affectedFile , cancellationToken , computeHash ) ;
330330 return affectedFile ;
331331 }
332- seenAffectedFiles . set ( affectedFile . path , true ) ;
333332 affectedFilesIndex ++ ;
334333 }
335334
@@ -549,7 +548,7 @@ namespace ts {
549548 * This is called after completing operation on the next affected file.
550549 * The operations here are postponed to ensure that cancellation during the iteration is handled correctly
551550 */
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 ) {
553552 if ( isBuildInfoEmit ) {
554553 state . emittedBuildInfo = true ;
555554 }
@@ -559,6 +558,9 @@ namespace ts {
559558 }
560559 else {
561560 state . seenAffectedFiles ! . set ( ( affected as SourceFile ) . path , true ) ;
561+ if ( isEmitResult ) {
562+ ( state . seenEmittedFiles || ( state . seenEmittedFiles = createMap ( ) ) ) . set ( ( affected as SourceFile ) . path , true ) ;
563+ }
562564 if ( isPendingEmit ) {
563565 state . affectedFilesPendingEmitIndex ! ++ ;
564566 }
@@ -576,6 +578,14 @@ namespace ts {
576578 return { result, affected } ;
577579 }
578580
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+
579589 /**
580590 * Gets the semantic diagnostics either from cache if present, or otherwise from program and caches it
581591 * 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 {
849859 }
850860
851861 const affected = Debug . assertDefined ( state . program ) ;
852- return toAffectedFileResult (
862+ return toAffectedFileEmitResult (
853863 state ,
854864 // When whole program is affected, do emit only once (eg when --out or --outFile is specified)
855865 // Otherwise just affected file
@@ -872,14 +882,14 @@ namespace ts {
872882 }
873883 }
874884
875- return toAffectedFileResult (
885+ return toAffectedFileEmitResult (
876886 state ,
877887 // When whole program is affected, do emit only once (eg when --out or --outFile is specified)
878888 // Otherwise just affected file
879889 Debug . assertDefined ( state . program ) . emit ( affected === state . program ? undefined : affected as SourceFile , writeFile || maybeBind ( host , host . writeFile ) , cancellationToken , emitOnlyDtsFiles , customTransformers ) ,
880890 affected ,
881- isPendingEmitFile
882- ) ;
891+ isPendingEmitFile ,
892+ ) ;
883893 }
884894
885895 /**
@@ -1036,7 +1046,7 @@ namespace ts {
10361046 compilerOptions : convertFromReusableCompilerOptions ( program . options , toAbsolutePath ) ,
10371047 referencedMap : getMapOfReferencedSet ( program . referencedMap , toPath ) ,
10381048 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 ] ) ,
10401050 hasReusableDiagnostic : true
10411051 } ;
10421052 return {
0 commit comments