Check if switch statements are exhaustive when their expressions is generic with a literal type constraint (#60644)

This commit is contained in:
Mateusz Burzyński
2024-12-02 21:12:58 +01:00
committed by GitHub
parent 97177722b8
commit 14c65b3119
5 changed files with 618 additions and 1 deletions

View File

@@ -38682,7 +38682,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
// A missing not-equal flag indicates that the type wasn't handled by some case.
return !someType(operandConstraint, t => getTypeFacts(t, notEqualFacts) === notEqualFacts);
}
const type = checkExpressionCached(node.expression);
const type = getBaseConstraintOrType(checkExpressionCached(node.expression));
if (!isLiteralType(type)) {
return false;
}