Conform more of the code base to strict null checking (#10147)

* Conform more of the code base to strict null checking

* More strict fixes

* More strict work

* Fix missing optional type

* Iterate
This commit is contained in:
Michael Telatynski 2023-02-13 17:01:43 +00:00 committed by GitHub
parent fa036a5080
commit da7aa4055e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
380 changed files with 682 additions and 694 deletions

View file

@ -32,12 +32,12 @@ import { Action } from "../dispatcher/actions";
// TODO: Move this and related files to the js-sdk or something once finalized.
export class Mjolnir {
private static instance: Mjolnir = null;
private static instance: Mjolnir | null = null;
private _lists: BanList[] = []; // eslint-disable-line @typescript-eslint/naming-convention
private _roomIds: string[] = []; // eslint-disable-line @typescript-eslint/naming-convention
private mjolnirWatchRef: string = null;
private dispatcherRef: string = null;
private mjolnirWatchRef: string | null = null;
private dispatcherRef: string | null = null;
public get roomIds(): string[] {
return this._roomIds;
@ -113,7 +113,7 @@ export class Mjolnir {
}
// get without creating the list
public getPersonalList(): BanList {
public getPersonalList(): BanList | null {
const personalRoomId = SettingsStore.getValue("mjolnirPersonalRoom");
if (!personalRoomId) return null;
@ -139,7 +139,7 @@ export class Mjolnir {
private onEvent = (event: MatrixEvent): void => {
if (!MatrixClientPeg.get()) return;
if (!this._roomIds.includes(event.getRoomId())) return;
if (!this._roomIds.includes(event.getRoomId()!)) return;
if (!ALL_RULE_TYPES.includes(event.getType())) return;
this.updateLists(this._roomIds);