mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Remove the rule that replaces a union of literal types with the base type when comparing equality to a type that isn't a union of literal types. (#27588)
type when comparing equality to a type that isn't a union of literal types. The rule is redundant because a primitive type is already directed- comparable to a value of that primitive type, and it causes errors to be missed when comparing a type parameter _constrained_ by a union of literal types to another union of literal types. The baseline changes look like improvements to me. Fixes #26758.
This commit is contained in:
committed by
Ryan Cavanaugh
parent
bd178746de
commit
6487d1ffe0
@@ -23320,12 +23320,6 @@ namespace ts {
|
||||
case SyntaxKind.ExclamationEqualsToken:
|
||||
case SyntaxKind.EqualsEqualsEqualsToken:
|
||||
case SyntaxKind.ExclamationEqualsEqualsToken:
|
||||
const leftIsLiteral = isLiteralType(leftType);
|
||||
const rightIsLiteral = isLiteralType(rightType);
|
||||
if (!leftIsLiteral || !rightIsLiteral) {
|
||||
leftType = leftIsLiteral ? getBaseTypeOfLiteralType(leftType) : leftType;
|
||||
rightType = rightIsLiteral ? getBaseTypeOfLiteralType(rightType) : rightType;
|
||||
}
|
||||
if (!isTypeEqualityComparableTo(leftType, rightType) && !isTypeEqualityComparableTo(rightType, leftType)) {
|
||||
reportOperatorError();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user