mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Fixed an issue in boolean comparison narrowing when the reference is an optional chain (#56504)
This commit is contained in:
@@ -27930,10 +27930,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
if (isMatchingConstructorReference(right)) {
|
||||
return narrowTypeByConstructor(type, operator, left, assumeTrue);
|
||||
}
|
||||
if (isBooleanLiteral(right)) {
|
||||
if (isBooleanLiteral(right) && !isAccessExpression(left)) {
|
||||
return narrowTypeByBooleanComparison(type, left, right, operator, assumeTrue);
|
||||
}
|
||||
if (isBooleanLiteral(left)) {
|
||||
if (isBooleanLiteral(left) && !isAccessExpression(right)) {
|
||||
return narrowTypeByBooleanComparison(type, right, left, operator, assumeTrue);
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user