@@ -10292,29 +10292,26 @@ namespace ts {
10292
10292
// Because the anyFunctionType is internal, it should not be exposed to the user by adding
10293
10293
// it as an inference candidate. Hopefully, a better candidate will come along that does
10294
10294
// not contain anyFunctionType when we come back to this argument for its second round
10295
- // of inference.
10295
+ // of inference. Also, we exclude inferences for silentNeverType which is used as a wildcard
10296
+ // when constructing types from type parameters that had no inference candidates.
10296
10297
if (source.flags & TypeFlags.ContainsAnyFunctionType || source === silentNeverType) {
10297
10298
return;
10298
10299
}
10299
- for (const inference of inferences) {
10300
- if (target === inference.typeParameter) {
10301
- // Even if an inference is marked as fixed, we can add candidates from inferences made
10302
- // from the return type of generic functions (which only happens when no other candidates
10303
- // are present).
10304
- if (!inference.isFixed) {
10305
- if (!inference.candidates || priority < inference.priority) {
10306
- inference.candidates = [source];
10307
- inference.priority = priority;
10308
- }
10309
- else if (priority === inference.priority) {
10310
- inference.candidates.push(source);
10311
- }
10312
- if (!(priority & InferencePriority.ReturnType) && target.flags & TypeFlags.TypeParameter && !isTypeParameterAtTopLevel(originalTarget, <TypeParameter>target)) {
10313
- inference.topLevel = false;
10314
- }
10300
+ const inference = getInferenceInfoForType(target);
10301
+ if (inference) {
10302
+ if (!inference.isFixed) {
10303
+ if (!inference.candidates || priority < inference.priority) {
10304
+ inference.candidates = [source];
10305
+ inference.priority = priority;
10306
+ }
10307
+ else if (priority === inference.priority) {
10308
+ inference.candidates.push(source);
10309
+ }
10310
+ if (!(priority & InferencePriority.ReturnType) && target.flags & TypeFlags.TypeParameter && !isTypeParameterAtTopLevel(originalTarget, <TypeParameter>target)) {
10311
+ inference.topLevel = false;
10315
10312
}
10316
- return;
10317
10313
}
10314
+ return;
10318
10315
}
10319
10316
}
10320
10317
else if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (<TypeReference>source).target === (<TypeReference>target).target) {
0 commit comments