mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-24 20:44:53 -05:00
Fixed an issue in boolean comparison narrowing when the reference is an optional chain (#56504)
This commit is contained in:
committed by
GitHub
parent
6f9d34985d
commit
d4fbc9b57d
@@ -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