I have the following code:
var a: boolean = ...; var b: boolean = ...; if (a ^ b) { // this line gives error // ... } However, the TypeScript compiler is giving an error:
error TS2113: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
Is it because bitwise operators only work for number? The code runs perfectly fine if written directly in JavaScript.
Is there any alternatives other than if (a ? !b : a) { ... }?
Update Given that both of them are boolean, I could just use a !== b