• Error
  • Reported by the type checker

TS2447

The '{0}' operator is not allowed for boolean types. Consider using '{1}' instead.

A bitwise operator such as | or & is applied to two booleans. Use the logical operator (|| or &&) instead.

What it means

|, & and ^ work on numbers bit by bit. Applying them to two booleans turns the values into numbers and back, which is almost always a typo for ||, && or !==.

Example

index.ts
declare const ready: boolean;
declare const forced: boolean;
export const go = ready | forced;
ts-r-check -p tsconfig.json --pretty false ts-r output
index.ts(3,19): error TS2447: The '|' operator is not allowed for boolean types. Consider using '||' instead.

Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.

How to fix

  • Use the operator the message suggests: || for |, && for &, !== for ^.
  • If you really want numeric bit operations, convert first: Number(ready) | Number(forced).