@@ -15229,15 +15229,23 @@ namespace ts {
15229
15229
const inference = inferences[i];
15230
15230
if (t === inference.typeParameter) {
15231
15231
if (fix && !inference.isFixed) {
15232
+ clearCachedInferences(inferences);
15232
15233
inference.isFixed = true;
15233
- inference.inferredType = undefined;
15234
15234
}
15235
15235
return getInferredType(context, i);
15236
15236
}
15237
15237
}
15238
15238
return t;
15239
15239
}
15240
15240
15241
+ function clearCachedInferences(inferences: InferenceInfo[]) {
15242
+ for (const inference of inferences) {
15243
+ if (!inference.isFixed) {
15244
+ inference.inferredType = undefined;
15245
+ }
15246
+ }
15247
+ }
15248
+
15241
15249
function createInferenceInfo(typeParameter: TypeParameter): InferenceInfo {
15242
15250
return {
15243
15251
typeParameter,
@@ -15517,17 +15525,17 @@ namespace ts {
15517
15525
if (contravariant && !bivariant) {
15518
15526
if (!contains(inference.contraCandidates, candidate)) {
15519
15527
inference.contraCandidates = append(inference.contraCandidates, candidate);
15520
- inference.inferredType = undefined ;
15528
+ clearCachedInferences(inferences) ;
15521
15529
}
15522
15530
}
15523
15531
else if (!contains(inference.candidates, candidate)) {
15524
15532
inference.candidates = append(inference.candidates, candidate);
15525
- inference.inferredType = undefined ;
15533
+ clearCachedInferences(inferences) ;
15526
15534
}
15527
15535
}
15528
15536
if (!(priority & InferencePriority.ReturnType) && target.flags & TypeFlags.TypeParameter && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, <TypeParameter>target)) {
15529
15537
inference.topLevel = false;
15530
- inference.inferredType = undefined ;
15538
+ clearCachedInferences(inferences) ;
15531
15539
}
15532
15540
}
15533
15541
return;
0 commit comments