@@ -796,6 +796,7 @@ namespace ts {
796
796
( result as SemanticDiagnosticsBuilderProgram ) . getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile ;
797
797
}
798
798
else if ( kind === BuilderProgramKind . EmitAndSemanticDiagnosticsBuilderProgram ) {
799
+ ( result as EmitAndSemanticDiagnosticsBuilderProgram ) . getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile ;
799
800
( result as EmitAndSemanticDiagnosticsBuilderProgram ) . emitNextAffectedFile = emitNextAffectedFile ;
800
801
}
801
802
else {
@@ -913,6 +914,11 @@ namespace ts {
913
914
) ;
914
915
}
915
916
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
+
916
922
// Get diagnostics for the affected file if its not ignored
917
923
if ( ignoreSourceFile && ignoreSourceFile ( affected as SourceFile ) ) {
918
924
// Get next affected file
@@ -951,18 +957,8 @@ namespace ts {
951
957
952
958
// When semantic builder asks for diagnostics of the whole program,
953
959
// 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 ) ) {
966
962
}
967
963
968
964
let diagnostics : Diagnostic [ ] | undefined ;
@@ -997,7 +993,7 @@ namespace ts {
997
993
return map ;
998
994
}
999
995
1000
- export function createBuildProgramUsingProgramBuildInfo ( program : ProgramBuildInfo ) : EmitAndSemanticDiagnosticsBuilderProgram & SemanticDiagnosticsBuilderProgram {
996
+ export function createBuildProgramUsingProgramBuildInfo ( program : ProgramBuildInfo ) : EmitAndSemanticDiagnosticsBuilderProgram {
1001
997
const fileInfos = createMapFromTemplate ( program . fileInfos ) ;
1002
998
const state : ReusableBuilderProgramState = {
1003
999
fileInfos,
@@ -1181,7 +1177,7 @@ namespace ts {
1181
1177
* The builder that can handle the changes in program and iterate through changed file to emit the files
1182
1178
* The semantic diagnostics are cached per file and managed by clearing for the changed/affected files
1183
1179
*/
1184
- export interface EmitAndSemanticDiagnosticsBuilderProgram extends BuilderProgram {
1180
+ export interface EmitAndSemanticDiagnosticsBuilderProgram extends SemanticDiagnosticsBuilderProgram {
1185
1181
/**
1186
1182
* Emits the next affected file's emit result (EmitResult and sourceFiles emitted) or returns undefined if iteration is complete
1187
1183
* The first of writeFile if provided, writeFile of BuilderProgramHost if provided, writeFile of compiler host
0 commit comments