Type Script. The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type
Делаю шахматы, пока только разбираюсь с TS и перерыв сайты, решения не нашла. Добавление к переменным Number не помогает. Проблема в условии, пишет об ошибке:
"The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type."
Конкретно на строку: if ((i+j)& 2 !== 0) {
Весь код файла:
import { Cell } from "./Cell";
import { Color } from "./Color";
export class Board {
cells: Cell[][] = []
public initCells() {
for (let i = 0; i < 8; i++) {
const row: Cell[] = []
for (let j = 0; j < 8; j++) {
if ((i+j)& 2 !== 0) {
row.push (new Cell (this, j, i, Color.BLACK, null))
}
else {
row.push(new Cell(this, j, i, Color.WHITE, null))
}
}
this.cells.push(row);
}
}
}