Skip to content

Commit e2c6818

Browse files
author
Cameron Boyd
committed
Return an error if either the left or right value are of type boolean
1 parent b504a1e commit e2c6818

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/compiler/checker.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40116,6 +40116,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4011640116
return sourceType;
4011740117
}
4011840118

40119+
function isBoolean(value: any): boolean {
40120+
return (value === typeof "boolean");
40121+
}
40122+
4011940123
/**
4012040124
* This is a *shallow* check: An expression is side-effect-free if the
4012140125
* evaluation of the expression *itself* cannot produce side effects.
@@ -40612,6 +40616,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4061240616
leftType = getBaseTypeOfLiteralTypeForComparison(checkNonNullType(leftType, left));
4061340617
rightType = getBaseTypeOfLiteralTypeForComparison(checkNonNullType(rightType, right));
4061440618
reportOperatorErrorUnless((left, right) => {
40619+
if (isBoolean(left) || isBoolean(right)) {
40620+
return true;
40621+
}
4061540622
if (isTypeAny(left) || isTypeAny(right)) {
4061640623
return true;
4061740624
}

0 commit comments

Comments
 (0)