@@ -46,6 +46,9 @@ func (mapper *projectReferenceFileMapper) getParseFileRedirect(file ast.HasFileN
4646}
4747
4848func (mapper * projectReferenceFileMapper ) getResolvedProjectReferences () []* tsoptions.ParsedCommandLine {
49+ if mapper .opts .Config .ConfigFile == nil {
50+ return nil
51+ }
4952 refs , ok := mapper .referencesInConfigFile [mapper .opts .Config .ConfigFile .SourceFile .Path ()]
5053 var result []* tsoptions.ParsedCommandLine
5154 if ok {
@@ -115,23 +118,44 @@ func (mapper *projectReferenceFileMapper) forEachResolvedProjectReference(
115118 seenRef := collections.NewSetWithSizeHint [tspath.Path ](len (mapper .referencesInConfigFile ))
116119 seenRef .Add (mapper .opts .Config .ConfigFile .SourceFile .Path ())
117120 refs := mapper .referencesInConfigFile [mapper .opts .Config .ConfigFile .SourceFile .Path ()]
118- mapper .forEachResolvedReferenceWorker (refs , fn , mapper .opts .Config , seenRef )
121+ mapper .forEachResolvedReferenceWorker (refs , func (path tspath.Path , config * tsoptions.ParsedCommandLine , parent * tsoptions.ParsedCommandLine , index int ) bool {
122+ fn (path , config , parent , index )
123+ return false
124+ }, mapper .opts .Config , seenRef )
119125}
120126
121127func (mapper * projectReferenceFileMapper ) forEachResolvedReferenceWorker (
122128 references []tspath.Path ,
123- fn func (path tspath.Path , config * tsoptions.ParsedCommandLine , parent * tsoptions.ParsedCommandLine , index int ),
129+ fn func (path tspath.Path , config * tsoptions.ParsedCommandLine , parent * tsoptions.ParsedCommandLine , index int ) bool ,
124130 parent * tsoptions.ParsedCommandLine ,
125131 seenRef * collections.Set [tspath.Path ],
126- ) {
132+ ) bool {
127133 for index , path := range references {
128134 if ! seenRef .AddIfAbsent (path ) {
129135 continue
130136 }
131137 config , _ := mapper .configToProjectReference [path ]
132- fn (path , config , parent , index )
133- mapper .forEachResolvedReferenceWorker (mapper .referencesInConfigFile [path ], fn , config , seenRef )
138+ if fn (path , config , parent , index ) {
139+ return true
140+ }
141+ if mapper .forEachResolvedReferenceWorker (mapper .referencesInConfigFile [path ], fn , config , seenRef ) {
142+ return true
143+ }
144+ }
145+ return false
146+ }
147+
148+ func (mapper * projectReferenceFileMapper ) forEachResolvedProjectReferenceInChildConfig (
149+ childConfig * tsoptions.ParsedCommandLine ,
150+ fn func (path tspath.Path , config * tsoptions.ParsedCommandLine , parent * tsoptions.ParsedCommandLine , index int ) bool ,
151+ ) bool {
152+ if childConfig == nil || childConfig .ConfigFile == nil {
153+ return false
134154 }
155+ seenRef := collections.NewSetWithSizeHint [tspath.Path ](len (mapper .referencesInConfigFile ))
156+ seenRef .Add (childConfig .ConfigFile .SourceFile .Path ())
157+ refs := mapper .referencesInConfigFile [childConfig .ConfigFile .SourceFile .Path ()]
158+ return mapper .forEachResolvedReferenceWorker (refs , fn , mapper .opts .Config , seenRef )
135159}
136160
137161func (mapper * projectReferenceFileMapper ) getSourceToDtsIfSymlink (file ast.HasFileName ) * tsoptions.SourceOutputAndProjectReference {
0 commit comments