Enable strictPropertyInitialization (#1909)

## Description:

Enable the tsconfig option `strictPropertyInitialization`.

Fixes #1907

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
This commit is contained in:
Scott Anderson
2025-08-23 19:21:40 -04:00
committed by GitHub
parent f5316cc378
commit 51519b0b9d
76 changed files with 599 additions and 367 deletions
+10 -8
View File
@@ -10,8 +10,8 @@ import { translateText } from "../../../client/Utils";
@customElement("win-modal")
export class WinModal extends LitElement implements Layer {
public game: GameView;
public eventBus: EventBus;
public game: GameView | undefined;
public eventBus: EventBus | undefined;
private hasShownDeathModal = false;
@@ -21,7 +21,7 @@ export class WinModal extends LitElement implements Layer {
@state()
showButtons = false;
private _title: string;
private _title = "";
// Override to prevent shadow DOM creation
createRenderRoot() {
@@ -137,7 +137,7 @@ export class WinModal extends LitElement implements Layer {
render() {
return html`
<div class="win-modal ${this.isVisible ? "visible" : ""}">
<h2>${this._title || ""}</h2>
<h2>${this._title}</h2>
${this.innerHtml()}
<div
class="button-container ${this.showButtons ? "visible" : "hidden"}"
@@ -175,7 +175,7 @@ export class WinModal extends LitElement implements Layer {
}
show() {
this.eventBus.emit(new GutterAdModalEvent(true));
this.eventBus?.emit(new GutterAdModalEvent(true));
setTimeout(() => {
this.isVisible = true;
this.requestUpdate();
@@ -187,7 +187,7 @@ export class WinModal extends LitElement implements Layer {
}
hide() {
this.eventBus.emit(new GutterAdModalEvent(false));
this.eventBus?.emit(new GutterAdModalEvent(false));
this.isVisible = false;
this.showButtons = false;
this.requestUpdate();
@@ -201,6 +201,7 @@ export class WinModal extends LitElement implements Layer {
init() {}
tick() {
if (this.game === undefined) throw new Error("Not initialized");
const myPlayer = this.game.myPlayer();
if (
!this.hasShownDeathModal &&
@@ -216,10 +217,11 @@ export class WinModal extends LitElement implements Layer {
const updates = this.game.updatesSinceLastTick();
const winUpdates = updates !== null ? updates[GameUpdateType.Win] : [];
winUpdates.forEach((wu) => {
if (this.game === undefined) return;
if (wu.winner === undefined) {
// ...
} else if (wu.winner[0] === "team") {
this.eventBus.emit(new SendWinnerEvent(wu.winner, wu.allPlayersStats));
this.eventBus?.emit(new SendWinnerEvent(wu.winner, wu.allPlayersStats));
if (wu.winner[1] === this.game.myPlayer()?.team()) {
this._title = translateText("win_modal.your_team");
} else {
@@ -233,7 +235,7 @@ export class WinModal extends LitElement implements Layer {
if (!winner?.isPlayer()) return;
const winnerClient = winner.clientID();
if (winnerClient !== null) {
this.eventBus.emit(
this.eventBus?.emit(
new SendWinnerEvent(["player", winnerClient], wu.allPlayersStats),
);
}