mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 07:45:18 -06:00
Fix type parameter inference cache invalidation
This commit is contained in:
parent
b0f050f4ee
commit
0e273c3e07
@ -15229,8 +15229,8 @@ namespace ts {
|
||||
const inference = inferences[i];
|
||||
if (t === inference.typeParameter) {
|
||||
if (fix && !inference.isFixed) {
|
||||
clearCachedInferences(inferences);
|
||||
inference.isFixed = true;
|
||||
inference.inferredType = undefined;
|
||||
}
|
||||
return getInferredType(context, i);
|
||||
}
|
||||
@ -15238,6 +15238,14 @@ namespace ts {
|
||||
return t;
|
||||
}
|
||||
|
||||
function clearCachedInferences(inferences: InferenceInfo[]) {
|
||||
for (const inference of inferences) {
|
||||
if (!inference.isFixed) {
|
||||
inference.inferredType = undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createInferenceInfo(typeParameter: TypeParameter): InferenceInfo {
|
||||
return {
|
||||
typeParameter,
|
||||
@ -15517,17 +15525,17 @@ namespace ts {
|
||||
if (contravariant && !bivariant) {
|
||||
if (!contains(inference.contraCandidates, candidate)) {
|
||||
inference.contraCandidates = append(inference.contraCandidates, candidate);
|
||||
inference.inferredType = undefined;
|
||||
clearCachedInferences(inferences);
|
||||
}
|
||||
}
|
||||
else if (!contains(inference.candidates, candidate)) {
|
||||
inference.candidates = append(inference.candidates, candidate);
|
||||
inference.inferredType = undefined;
|
||||
clearCachedInferences(inferences);
|
||||
}
|
||||
}
|
||||
if (!(priority & InferencePriority.ReturnType) && target.flags & TypeFlags.TypeParameter && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, <TypeParameter>target)) {
|
||||
inference.topLevel = false;
|
||||
inference.inferredType = undefined;
|
||||
clearCachedInferences(inferences);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user