Conform more of the codebase to strictNullChecks (#11134)
This commit is contained in:
parent
3d886de5b0
commit
e1cad41bc3
15 changed files with 44 additions and 36 deletions
|
@ -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,
|
||||
|
|
|
@ -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`;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ const RoomListHeader: React.FC<IProps> = ({ onVisibilityChange }) => {
|
|||
contextMenu = (
|
||||
<ContextMenuComponent
|
||||
{...contextMenuBelow(mainMenuHandle.current.getBoundingClientRect())}
|
||||
space={activeSpace}
|
||||
space={activeSpace!}
|
||||
onFinished={closeMainMenu}
|
||||
hideHeader={true}
|
||||
/>
|
||||
|
|
|
@ -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 });
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue