File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -1221,6 +1221,9 @@ namespace ts {
12211221 function doesStructuralPermitResolutionsReuse ( ) : boolean {
12221222 switch ( structuralIsReused ) {
12231223 case StructureIsReused . Not : return false ;
1224+ case StructureIsReused . SafeProjectReferenceModules :
1225+ return file . resolvedModules !== undefined &&
1226+ isSourceOfProjectReferenceRedirect ( file . originalFileName ) ;
12241227 case StructureIsReused . SafeModules : return true ;
12251228 case StructureIsReused . Completely : return true ;
12261229
@@ -1293,7 +1296,10 @@ namespace ts {
12931296
12941297 function tryReuseStructureFromOldProgram ( ) : StructureIsReused {
12951298 if ( ! oldProgram ) {
1296- return StructureIsReused . Not ;
1299+ // During initial program creation, root files may import files from project
1300+ // references that were previously loaded. Those resolutions are safe to reuse
1301+ // since another program instance kept them up to date.
1302+ return StructureIsReused . SafeProjectReferenceModules ;
12971303 }
12981304
12991305 // check properties that can affect structure of the program or module resolution strategy
Original file line number Diff line number Diff line change @@ -3824,9 +3824,10 @@ namespace ts {
38243824 /* @internal */
38253825 /** "Structure" refers to the SourceFile graph of a Program linked by module resolutions. */
38263826 export const enum StructureIsReused {
3827- Not = 0 , // The entire Program must be (re)created.
3828- SafeModules = 1 << 0 , // SourceFile objects need to be rediscovered, but module resolutions can be reused.
3829- Completely = 1 << 1 , // SourceFile objects and module resolutions can be reused from an old Program.
3827+ Not = 0 , // The entire Program must be (re)created.
3828+ SafeProjectReferenceModules = 1 << 0 , // SourceFile objects need to be rediscovered, but module resolutions within project reference sources may be reused.
3829+ SafeModules = 1 << 1 , // SourceFile objects need to be rediscovered, but module resolutions can be reused.
3830+ Completely = 1 << 2 , // SourceFile objects and module resolutions can be reused from an old Program.
38303831 }
38313832
38323833 export type CustomTransformerFactory = ( context : TransformationContext ) => CustomTransformer ;
You can’t perform that action at this time.
0 commit comments