I have such code:
export class Board implements IBoard {
choosedPiece = false;
constructor() {
this.clicked();
}
}
and functions like this:
public pieceOnClick(target: EventTarget): void {
if (this.choosedPiece) {
const clickedPiece = this.findPiecePosition((target as HTMLDivElement));
if (clickedPiece.instance !== null) {
this.choosedPiece = false;
this.clickedEl(target);
}
}
}
clicked(): void {
this.chessBoard.addEventListener('click', ({target}) => {
if(!this.clickedEl(target)){
this.clickPiece(target);
}
})
}
And now I have such an error Argument of type 'EventTarget | null' is not assignable to parameter of type 'EventTarget'. Type 'null' is not assignable to type 'EventTarget'.
How to handle it?