Conform more of the codebase to strictNullChecks (#11134)

This commit is contained in:
Michael Telatynski 2023-06-27 17:39:56 +01:00 committed by GitHub
parent 3d886de5b0
commit e1cad41bc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 44 additions and 36 deletions

View file

@ -1704,7 +1704,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
} catch (error) {
logger.error(`Failed to reject invite: ${error}`);
const msg = error.message ? error.message : JSON.stringify(error);
const msg = error instanceof Error ? error.message : JSON.stringify(error);
Modal.createDialog(ErrorDialog, {
title: _t("Failed to reject invite"),
description: msg,

View file

@ -700,7 +700,7 @@ export default class ScrollPanel extends React.Component<IProps> {
const trackedNode = this.getTrackedNode();
if (trackedNode) {
const newBottomOffset = this.topFromBottom(trackedNode);
const bottomDiff = newBottomOffset - scrollState.bottomOffset;
const bottomDiff = newBottomOffset - (scrollState.bottomOffset ?? 0);
this.bottomGrowth += bottomDiff;
scrollState.bottomOffset = newBottomOffset;
const newHeight = `${this.getListHeight()}px`;

View file

@ -599,7 +599,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
if (!this.timelineWindow?.canPaginate(dir)) {
debuglog("can't", dir, "paginate any further");
this.setState<null>({ [canPaginateKey]: false });
this.setState({ [canPaginateKey]: false } as Pick<IState, typeof canPaginateKey>);
return Promise.resolve(false);
}
@ -609,7 +609,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
}
debuglog("Initiating paginate; backwards:" + backwards);
this.setState<null>({ [paginatingKey]: true });
this.setState({ [paginatingKey]: true } as Pick<IState, typeof paginatingKey>);
return this.onPaginationRequest(this.timelineWindow, dir, PAGINATE_SIZE).then(async (r) => {
if (this.unmounted) {
@ -2012,7 +2012,7 @@ class TimelinePanel extends React.Component<IProps, IState> {
return receiptStore?.getEventReadUpTo(myUserId, ignoreSynthesized) ?? null;
}
private setReadMarker(eventId: string | null, eventTs: number, inhibitSetState = false): void {
private setReadMarker(eventId: string | null, eventTs?: number, inhibitSetState = false): void {
const roomId = this.props.timelineSet.room?.roomId;
// don't update the state (and cause a re-render) if there is
@ -2023,7 +2023,11 @@ class TimelinePanel extends React.Component<IProps, IState> {
// in order to later figure out if the read marker is
// above or below the visible timeline, we stash the timestamp.
TimelinePanel.roomReadMarkerTsMap[roomId ?? ""] = eventTs;
if (eventTs !== undefined) {
TimelinePanel.roomReadMarkerTsMap[roomId ?? ""] = eventTs;
} else {
delete TimelinePanel.roomReadMarkerTsMap[roomId ?? ""];
}
if (inhibitSetState) {
return;

View file

@ -18,7 +18,7 @@ import React from "react";
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
import { _t } from "../../../languageHandler";
import AccessibleButton from "../elements/AccessibleButton";
import AccessibleButton, { ButtonEvent } from "../elements/AccessibleButton";
interface IProps {
mxEvent: MatrixEvent;
@ -26,7 +26,7 @@ interface IProps {
}
export default class MjolnirBody extends React.Component<IProps> {
private onAllowClick = (e: React.MouseEvent): void => {
private onAllowClick = (e: ButtonEvent): void => {
e.preventDefault();
e.stopPropagation();

View file

@ -171,7 +171,7 @@ const RoomListHeader: React.FC<IProps> = ({ onVisibilityChange }) => {
contextMenu = (
<ContextMenuComponent
{...contextMenuBelow(mainMenuHandle.current.getBoundingClientRect())}
space={activeSpace}
space={activeSpace!}
onFinished={closeMainMenu}
hideHeader={true}
/>

View file

@ -155,7 +155,7 @@ export default class RoomPreviewBar extends React.Component<IProps, IState> {
);
this.setState({ invitedEmailMxid: result.mxid });
} catch (err) {
this.setState({ threePidFetchError: err });
this.setState({ threePidFetchError: err as MatrixError });
}
this.setState({ busy: false });
}