@@ -10292,29 +10292,26 @@ namespace ts {
1029210292 // Because the anyFunctionType is internal, it should not be exposed to the user by adding
1029310293 // it as an inference candidate. Hopefully, a better candidate will come along that does
1029410294 // 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.
1029610297 if (source.flags & TypeFlags.ContainsAnyFunctionType || source === silentNeverType) {
1029710298 return;
1029810299 }
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;
1031510312 }
10316- return;
1031710313 }
10314+ return;
1031810315 }
1031910316 }
1032010317 else if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (<TypeReference>source).target === (<TypeReference>target).target) {
0 commit comments