@@ -20,15 +20,15 @@ namespace ts {
20
20
21
21
export type ReusableDiagnosticMessageChain = DiagnosticMessageChain ;
22
22
23
- export interface ReusableBuilderProgramState extends ReusableBuilderState {
23
+ export interface ReusableBuilderProgramState extends BuilderState {
24
24
/**
25
25
* Cache of bind and check diagnostics for files with their Path being the key
26
26
*/
27
- semanticDiagnosticsPerFile ?: ReadonlyESMap < Path , readonly ReusableDiagnostic [ ] | readonly Diagnostic [ ] > | undefined ;
27
+ semanticDiagnosticsPerFile ?: ESMap < Path , readonly ReusableDiagnostic [ ] | readonly Diagnostic [ ] > | undefined ;
28
28
/**
29
29
* The map has key by source file's path that has been changed
30
30
*/
31
- changedFilesSet : ReadonlySet < Path > ;
31
+ changedFilesSet : Set < Path > ;
32
32
/**
33
33
* Set of affected files being iterated
34
34
*/
@@ -41,11 +41,11 @@ namespace ts {
41
41
* Map of file signatures, with key being file path, calculated while getting current changed file's affected files
42
42
* These will be committed whenever the iteration through affected files of current changed file is complete
43
43
*/
44
- currentAffectedFilesSignatures ?: ReadonlyESMap < Path , string > | undefined ;
44
+ currentAffectedFilesSignatures ?: ESMap < Path , string > | undefined ;
45
45
/**
46
46
* Newly computed visible to outside referencedSet
47
47
*/
48
- currentAffectedFilesExportedModulesMap ?: BuilderState . ReadonlyManyToManyPathMap | undefined ;
48
+ currentAffectedFilesExportedModulesMap ?: BuilderState . ManyToManyPathMap | undefined ;
49
49
/**
50
50
* True if the semantic diagnostics were copied from the old state
51
51
*/
@@ -65,7 +65,7 @@ namespace ts {
65
65
/**
66
66
* Files pending to be emitted kind.
67
67
*/
68
- affectedFilesPendingEmitKind ?: ReadonlyESMap < Path , BuilderFileEmit > | undefined ;
68
+ affectedFilesPendingEmitKind ?: ESMap < Path , BuilderFileEmit > | undefined ;
69
69
/**
70
70
* Current index to retrieve pending affected file
71
71
*/
@@ -74,11 +74,18 @@ namespace ts {
74
74
* true if semantic diagnostics are ReusableDiagnostic instead of Diagnostic
75
75
*/
76
76
hasReusableDiagnostic ?: true ;
77
-
78
- emitSignatures ?: ReadonlyESMap < Path , string > ;
77
+ /**
78
+ * Hash of d.ts emitted for the file, use to track when emit of d.ts changes
79
+ */
80
+ emitSignatures ?: ESMap < Path , string > ;
81
+ /**
82
+ * Hash of d.ts emit with --out
83
+ */
79
84
outSignature ?: string ;
85
+ /**
86
+ * Time when d.ts was modified
87
+ */
80
88
dtsChangeTime : number | undefined ;
81
- hasChangedEmitSignature ?: boolean ;
82
89
}
83
90
84
91
export const enum BuilderFileEmit {
@@ -90,38 +97,15 @@ namespace ts {
90
97
* State to store the changed files, affected files and cache semantic diagnostics
91
98
*/
92
99
// TODO: GH#18217 Properties of this interface are frequently asserted to be defined.
93
- export interface BuilderProgramState extends BuilderState {
100
+ export interface BuilderProgramState extends BuilderState , ReusableBuilderProgramState {
94
101
/**
95
102
* Cache of bind and check diagnostics for files with their Path being the key
96
103
*/
97
104
semanticDiagnosticsPerFile : ESMap < Path , readonly Diagnostic [ ] > | undefined ;
98
- /**
99
- * The map has key by source file's path that has been changed
100
- */
101
- changedFilesSet : Set < Path > ;
102
- /**
103
- * Set of affected files being iterated
104
- */
105
- affectedFiles : readonly SourceFile [ ] | undefined ;
106
105
/**
107
106
* Current index to retrieve affected file from
108
107
*/
109
108
affectedFilesIndex : number | undefined ;
110
- /**
111
- * Current changed file for iterating over affected files
112
- */
113
- currentChangedFilePath : Path | undefined ;
114
- /**
115
- * Map of file signatures, with key being file path, calculated while getting current changed file's affected files
116
- * These will be committed whenever the iteration through affected files of current changed file is complete
117
- */
118
- currentAffectedFilesSignatures : ESMap < Path , string > | undefined ;
119
- /**
120
- * Newly computed visible to outside referencedSet
121
- * We need to store the updates separately in case the in-progress build is cancelled
122
- * and we need to roll back.
123
- */
124
- currentAffectedFilesExportedModulesMap : BuilderState . ManyToManyPathMap | undefined ;
125
109
/**
126
110
* Already seen affected files
127
111
*/
@@ -131,33 +115,13 @@ namespace ts {
131
115
*/
132
116
cleanedDiagnosticsOfLibFiles ?: boolean ;
133
117
/**
134
- * True if the semantic diagnostics were copied from the old state
135
- */
136
- semanticDiagnosticsFromOldState ?: Set < Path > ;
137
- /**
138
- * program corresponding to this state
139
- */
140
- program : Program | undefined ;
141
- /**
142
- * compilerOptions for the program
118
+ * Records if change in dts emit was detected
143
119
*/
144
- compilerOptions : CompilerOptions ;
145
- emitSignatures ?: ESMap < Path , string > ;
146
- outSignature ?: string ;
147
- dtsChangeTime : number | undefined ;
148
- hasChangedEmitSignature ?: boolean ;
120
+ hasChangedEmitSignature ?: boolean ;
149
121
/**
150
122
* Files pending to be emitted
151
123
*/
152
124
affectedFilesPendingEmit : Path [ ] | undefined ;
153
- /**
154
- * Files pending to be emitted kind.
155
- */
156
- affectedFilesPendingEmitKind : ESMap < Path , BuilderFileEmit > | undefined ;
157
- /**
158
- * Current index to retrieve pending affected file
159
- */
160
- affectedFilesPendingEmitIndex : number | undefined ;
161
125
/**
162
126
* true if build info is emitted
163
127
*/
@@ -196,7 +160,7 @@ namespace ts {
196
160
state . outSignature = oldState ?. outSignature ;
197
161
}
198
162
state . changedFilesSet = new Set ( ) ;
199
- state . dtsChangeTime = oldState ?. dtsChangeTime ;
163
+ state . dtsChangeTime = compilerOptions . composite ? oldState ?. dtsChangeTime : undefined ;
200
164
201
165
const useOldState = BuilderState . canReuseOldState ( state . referencedMap , oldState ) ;
202
166
const oldCompilerOptions = useOldState ? oldState ! . compilerOptions : undefined ;
@@ -507,7 +471,7 @@ namespace ts {
507
471
) ;
508
472
return ;
509
473
}
510
- Debug . assert ( state . hasCalledUpdateShapeSignature . has ( affectedFile . resolvedPath ) || state . currentAffectedFilesSignatures ?. has ( affectedFile . resolvedPath ) , `Signature not updated for affected file: ${ affectedFile . fileName } ` ) ;
474
+ Debug . assert ( state . hasCalledUpdateShapeSignature ? .has ( affectedFile . resolvedPath ) || state . currentAffectedFilesSignatures ?. has ( affectedFile . resolvedPath ) , `Signature not updated for affected file: ${ affectedFile . fileName } ` ) ;
511
475
if ( state . compilerOptions . assumeChangesOnlyAffectDirectDependencies ) return ;
512
476
handleDtsMayChangeOfReferencingExportOfAffectedFile ( state , affectedFile , cancellationToken , computeHash , host ) ;
513
477
}
@@ -844,7 +808,7 @@ namespace ts {
844
808
/**
845
809
* Gets the program information to be emitted in buildInfo so that we can use it to create new program
846
810
*/
847
- function getProgramBuildInfo ( state : ReusableBuilderProgramState , getCanonicalFileName : GetCanonicalFileName , host : BuilderProgramHost ) : ProgramBuildInfo | undefined {
811
+ function getProgramBuildInfo ( state : BuilderProgramState , getCanonicalFileName : GetCanonicalFileName , host : BuilderProgramHost ) : ProgramBuildInfo | undefined {
848
812
const outFilePath = outFile ( state . compilerOptions ) ;
849
813
if ( outFilePath && ! state . compilerOptions . composite ) return ;
850
814
const currentDirectory = Debug . checkDefined ( state . program ) . getCurrentDirectory ( ) ;
@@ -924,9 +888,7 @@ namespace ts {
924
888
value . length ?
925
889
[
926
890
toFileId ( key ) ,
927
- state . hasReusableDiagnostic ?
928
- value as readonly ReusableDiagnostic [ ] :
929
- convertToReusableDiagnostics ( value as readonly Diagnostic [ ] , relativeToBuildInfo )
891
+ convertToReusableDiagnostics ( value , relativeToBuildInfo )
930
892
] :
931
893
toFileId ( key )
932
894
) ;
@@ -1541,7 +1503,7 @@ namespace ts {
1541
1503
}
1542
1504
}
1543
1505
1544
- export function createRedirectedBuilderProgram ( getState : ( ) => { program : Program | undefined ; compilerOptions : CompilerOptions ; } , configFileParsingDiagnostics : readonly Diagnostic [ ] ) : BuilderProgram {
1506
+ export function createRedirectedBuilderProgram ( getState : ( ) => { program ? : Program | undefined ; compilerOptions : CompilerOptions ; } , configFileParsingDiagnostics : readonly Diagnostic [ ] ) : BuilderProgram {
1545
1507
return {
1546
1508
getState : notImplemented ,
1547
1509
backupState : noop ,
0 commit comments