diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9f3c8fa6fd7..fb2e2ba3413 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12777,7 +12777,9 @@ namespace ts { const widenLiteralTypes = inference.topLevel && !hasPrimitiveConstraint(inference.typeParameter) && (inference.isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), inference.typeParameter)); - const baseCandidates = widenLiteralTypes ? sameMap(candidates, getWidenedLiteralType) : candidates; + const baseCandidates = widenLiteralTypes ? sameMap(candidates, getWidenedLiteralType) : + hasPrimitiveConstraint(inference.typeParameter) ? sameMap(candidates, getRegularTypeOfLiteralType) : + candidates; // If all inferences were made from contravariant positions, infer a common subtype. Otherwise, if // union types were requested or if all inferences were made from the return type position, infer a // union type. Otherwise, infer a common supertype.