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
380 changed files with 682 additions and 694 deletions
+3 -3
View File
@@ -31,10 +31,10 @@ import { determineCreateRoomEncryptionOption, Member } from "../../../src/utils/
* @returns {Promise<LocalRoom>} Resolves to the new local room
*/
export async function createDmLocalRoom(client: MatrixClient, targets: Member[]): Promise<LocalRoom> {
const userId = client.getUserId();
const userId = client.getUserId()!;
const localRoom = new LocalRoom(LOCAL_ROOM_ID_PREFIX + client.makeTxnId(), client, userId);
const events = [];
const events: MatrixEvent[] = [];
events.push(
new MatrixEvent({
@@ -121,7 +121,7 @@ export async function createDmLocalRoom(client: MatrixClient, targets: Member[])
localRoom.updateMyMembership("join");
localRoom.addLiveEvents(events);
localRoom.currentState.setStateEvents(events);
localRoom.name = localRoom.getDefaultRoomName(client.getUserId());
localRoom.name = localRoom.getDefaultRoomName(client.getUserId()!);
client.store.storeRoom(localRoom);
return localRoom;
+6 -3
View File
@@ -35,7 +35,7 @@ export async function startDm(client: MatrixClient, targets: Member[], showSpinn
const targetIds = targets.map((t) => t.userId);
// Check if there is already a DM with these people and reuse it if possible.
let existingRoom: Room;
let existingRoom: Room | undefined;
if (targetIds.length === 1) {
existingRoom = findDMForUser(client, targetIds[0]);
} else {
@@ -66,12 +66,15 @@ export async function startDm(client: MatrixClient, targets: Member[], showSpinn
}
if (targetIds.length > 1) {
createRoomOptions.createOpts = targetIds.reduce(
createRoomOptions.createOpts = targetIds.reduce<{
invite_3pid: IInvite3PID[];
invite: string[];
}>(
(roomOptions, address) => {
const type = getAddressType(address);
if (type === "email") {
const invite: IInvite3PID = {
id_server: client.getIdentityServerUrl(true),
id_server: client.getIdentityServerUrl(true)!,
medium: "email",
address,
};