Improve typescript null checking in places (#10073 (#10073

* Improve typescript null checking in places

* Iterate

* Fix Timer.ts
This commit is contained in:
Michael Telatynski 2023-02-03 15:27:47 +00:00 committed by GitHub
parent 97506cbcdb
commit 9743852380
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 155 additions and 154 deletions

View file

@ -268,7 +268,7 @@ export default async function createRoom(opts: IOpts): Promise<string | null> {
}
let modal;
if (opts.spinner) modal = Modal.createDialog(Spinner, null, "mx_Dialog_spinner");
if (opts.spinner) modal = Modal.createDialog(Spinner, undefined, "mx_Dialog_spinner");
let roomId: string;
let room: Promise<Room>;
@ -417,9 +417,9 @@ export async function ensureVirtualRoomExists(
client: MatrixClient,
userId: string,
nativeRoomId: string,
): Promise<string> {
): Promise<string | null> {
const existingDMRoom = findDMForUser(client, userId);
let roomId;
let roomId: string | null;
if (existingDMRoom) {
roomId = existingDMRoom.roomId;
} else {
@ -440,13 +440,13 @@ export async function ensureVirtualRoomExists(
return roomId;
}
export async function ensureDMExists(client: MatrixClient, userId: string): Promise<string> {
export async function ensureDMExists(client: MatrixClient, userId: string): Promise<string | null> {
const existingDMRoom = findDMForUser(client, userId);
let roomId;
let roomId: string | null;
if (existingDMRoom) {
roomId = existingDMRoom.roomId;
} else {
let encryption: boolean = undefined;
let encryption: boolean | undefined;
if (privateShouldBeEncrypted()) {
encryption = await canEncryptToAllUsers(client, [userId]);
}