@@ -1017,6 +1017,27 @@ func (r resolverQuery) parseTSConfig(file string, visited map[string]bool) (*TSC
1017
1017
// and because it would deadlock since we're currently in the middle of
1018
1018
// populating the directory info cache.
1019
1019
1020
+ maybeFinishOurSearch := func (base * TSConfigJSON , err error , extendsFile string ) (* TSConfigJSON , bool ) {
1021
+ if err == nil {
1022
+ return base , true
1023
+ }
1024
+
1025
+ if err == syscall .ENOENT {
1026
+ // Return false to indicate that we should continue searching
1027
+ return nil , false
1028
+ }
1029
+
1030
+ if err == errParseErrorImportCycle {
1031
+ r .log .AddID (logger .MsgID_TsconfigJSON_Cycle , logger .Warning , & tracker , extendsRange ,
1032
+ fmt .Sprintf ("Base config file %q forms cycle" , extends ))
1033
+ } else if err != errParseErrorAlreadyLogged {
1034
+ r .log .AddError (& tracker , extendsRange ,
1035
+ fmt .Sprintf ("Cannot read file %q: %s" ,
1036
+ PrettyPath (r .fs , logger.Path {Text : extendsFile , Namespace : "file" }), err .Error ()))
1037
+ }
1038
+ return nil , true
1039
+ }
1040
+
1020
1041
// Check for a Yarn PnP manifest and use that to rewrite the path
1021
1042
if IsPackagePath (extends ) {
1022
1043
pnpData := r .pnpManifest
@@ -1087,19 +1108,9 @@ func (r resolverQuery) parseTSConfig(file string, visited map[string]bool) (*TSC
1087
1108
}
1088
1109
}
1089
1110
1090
- if err == nil {
1091
- return base
1092
- } else if err == syscall .ENOENT {
1093
- continue
1094
- } else if err == errParseErrorImportCycle {
1095
- r .log .AddID (logger .MsgID_TsconfigJSON_Cycle , logger .Warning , & tracker , extendsRange ,
1096
- fmt .Sprintf ("Base config file %q forms cycle" , extends ))
1097
- } else if err != errParseErrorAlreadyLogged {
1098
- r .log .AddError (& tracker , extendsRange ,
1099
- fmt .Sprintf ("Cannot read file %q: %s" ,
1100
- PrettyPath (r .fs , logger.Path {Text : fileToCheck , Namespace : "file" }), err .Error ()))
1111
+ if result , shouldReturn := maybeFinishOurSearch (base , err , fileToCheck ); shouldReturn {
1112
+ return result
1101
1113
}
1102
- return nil
1103
1114
}
1104
1115
}
1105
1116
@@ -1152,18 +1163,8 @@ func (r resolverQuery) parseTSConfig(file string, visited map[string]bool) (*TSC
1152
1163
}
1153
1164
}
1154
1165
1155
- if err == nil {
1156
- return base
1157
- } else if err != syscall .ENOENT {
1158
- if err == errParseErrorImportCycle {
1159
- r .log .AddID (logger .MsgID_TsconfigJSON_Cycle , logger .Warning , & tracker , extendsRange ,
1160
- fmt .Sprintf ("Base config file %q forms cycle" , extends ))
1161
- } else if err != errParseErrorAlreadyLogged {
1162
- r .log .AddError (& tracker , extendsRange ,
1163
- fmt .Sprintf ("Cannot read file %q: %s" ,
1164
- PrettyPath (r .fs , logger.Path {Text : extendsFile , Namespace : "file" }), err .Error ()))
1165
- }
1166
- return nil
1166
+ if result , shouldReturn := maybeFinishOurSearch (base , err , extendsFile ); shouldReturn {
1167
+ return result
1167
1168
}
1168
1169
}
1169
1170
0 commit comments