mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-11 20:37:46 -05:00
Reintroduce cloneInferredPartOfContext to fix overloaded inferences with returnMappers (#33478)
This commit is contained in:
@@ -15408,6 +15408,13 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
function cloneInferredPartOfContext(context: InferenceContext): InferenceContext | undefined {
|
||||
const inferences = filter(context.inferences, hasInferenceCandidates);
|
||||
return inferences.length ?
|
||||
createInferenceContextWorker(map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) :
|
||||
undefined;
|
||||
}
|
||||
|
||||
function getMapperFromContext<T extends InferenceContext | undefined>(context: T): TypeMapper | T & undefined {
|
||||
return context && context.mapper;
|
||||
}
|
||||
@@ -21465,7 +21472,7 @@ namespace ts {
|
||||
const returnContext = createInferenceContext(signature.typeParameters!, signature, context.flags);
|
||||
const returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
|
||||
inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
|
||||
context.returnMapper = some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(returnContext) : undefined;
|
||||
context.returnMapper = some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user