-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
Consider:
var a: boolean = ...;
var b: boolean = ...;
if (a ^ b) {
// ...
}
Currently attempting to use the ^
operator on boolean
values fails with:
error TS2113: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
The |
and &
bitwise operators have logical counterparts, ||
and &&
. No such ^^
is available.
JavaScript allows bitwise XOR to apply to boolean
values.
Currently workarounds are:
- casting:
<number><any>a ^ <number><any>b
- using a negated equality test:
a !== b
The XOR operator is clearer than both of these.
Metadata
Metadata
Assignees
Labels
DeclinedThe issue was declined as something which matches the TypeScript visionThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScriptAn idea for TypeScript