@@ -796,6 +796,7 @@ namespace ts {
796796 ( result as SemanticDiagnosticsBuilderProgram ) . getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile ;
797797 }
798798 else if ( kind === BuilderProgramKind . EmitAndSemanticDiagnosticsBuilderProgram ) {
799+ ( result as EmitAndSemanticDiagnosticsBuilderProgram ) . getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile ;
799800 ( result as EmitAndSemanticDiagnosticsBuilderProgram ) . emitNextAffectedFile = emitNextAffectedFile ;
800801 }
801802 else {
@@ -913,6 +914,11 @@ namespace ts {
913914 ) ;
914915 }
915916
917+ // Add file to affected file pending emit to handle for later emit time
918+ if ( kind === BuilderProgramKind . EmitAndSemanticDiagnosticsBuilderProgram ) {
919+ addToAffectedFilesPendingEmit ( state , [ ( affected as SourceFile ) . path ] ) ;
920+ }
921+
916922 // Get diagnostics for the affected file if its not ignored
917923 if ( ignoreSourceFile && ignoreSourceFile ( affected as SourceFile ) ) {
918924 // Get next affected file
@@ -951,18 +957,8 @@ namespace ts {
951957
952958 // When semantic builder asks for diagnostics of the whole program,
953959 // ensure that all the affected files are handled
954- let affected : SourceFile | Program | undefined ;
955- let affectedFilesPendingEmit : Path [ ] | undefined ;
956- while ( affected = getNextAffectedFile ( state , cancellationToken , computeHash ) ) {
957- if ( affected !== state . program && kind === BuilderProgramKind . EmitAndSemanticDiagnosticsBuilderProgram ) {
958- ( affectedFilesPendingEmit || ( affectedFilesPendingEmit = [ ] ) ) . push ( ( affected as SourceFile ) . path ) ;
959- }
960- doneWithAffectedFile ( state , affected ) ;
961- }
962-
963- // In case of emit builder, cache the files to be emitted
964- if ( affectedFilesPendingEmit ) {
965- addToAffectedFilesPendingEmit ( state , affectedFilesPendingEmit ) ;
960+ // tslint:disable-next-line no-empty
961+ while ( getSemanticDiagnosticsOfNextAffectedFile ( cancellationToken ) ) {
966962 }
967963
968964 let diagnostics : Diagnostic [ ] | undefined ;
@@ -997,7 +993,7 @@ namespace ts {
997993 return map ;
998994 }
999995
1000- export function createBuildProgramUsingProgramBuildInfo ( program : ProgramBuildInfo ) : EmitAndSemanticDiagnosticsBuilderProgram & SemanticDiagnosticsBuilderProgram {
996+ export function createBuildProgramUsingProgramBuildInfo ( program : ProgramBuildInfo ) : EmitAndSemanticDiagnosticsBuilderProgram {
1001997 const fileInfos = createMapFromTemplate ( program . fileInfos ) ;
1002998 const state : ReusableBuilderProgramState = {
1003999 fileInfos,
@@ -1181,7 +1177,7 @@ namespace ts {
11811177 * The builder that can handle the changes in program and iterate through changed file to emit the files
11821178 * The semantic diagnostics are cached per file and managed by clearing for the changed/affected files
11831179 */
1184- export interface EmitAndSemanticDiagnosticsBuilderProgram extends BuilderProgram {
1180+ export interface EmitAndSemanticDiagnosticsBuilderProgram extends SemanticDiagnosticsBuilderProgram {
11851181 /**
11861182 * Emits the next affected file's emit result (EmitResult and sourceFiles emitted) or returns undefined if iteration is complete
11871183 * The first of writeFile if provided, writeFile of BuilderProgramHost if provided, writeFile of compiler host
0 commit comments