Make more of the codebase conform to strict types (#10857)
This commit is contained in:
parent
7f017a84c2
commit
6a3f59cc76
45 changed files with 127 additions and 121 deletions
|
@ -56,7 +56,7 @@ class FilePanel extends React.Component<IProps, IState> {
|
|||
// This is used to track if a decrypted event was a live event and should be
|
||||
// added to the timeline.
|
||||
private decryptingEvents = new Set<string>();
|
||||
public noRoom: boolean;
|
||||
public noRoom = false;
|
||||
private card = createRef<HTMLDivElement>();
|
||||
|
||||
public state: IState = {
|
||||
|
|
|
@ -125,7 +125,7 @@ export function GenericDropdownMenu<T>({
|
|||
}: IProps<T>): JSX.Element {
|
||||
const [menuDisplayed, button, openMenu, closeMenu] = useContextMenu<HTMLElement>();
|
||||
|
||||
const selected: GenericDropdownMenuItem<T> | null = options
|
||||
const selected: GenericDropdownMenuItem<T> | undefined = options
|
||||
.flatMap((it) => (isGenericDropdownMenuGroup(it) ? [it, ...it.options] : [it]))
|
||||
.find((option) => (toKey ? toKey(option.key) === toKey(value) : option.key === value));
|
||||
let contextMenuOptions: JSX.Element;
|
||||
|
|
|
@ -181,19 +181,19 @@ export default class ScrollPanel extends React.Component<IProps> {
|
|||
private unmounted = false;
|
||||
private scrollTimeout?: Timer;
|
||||
// Are we currently trying to backfill?
|
||||
private isFilling: boolean;
|
||||
private isFilling = false;
|
||||
// Is the current fill request caused by a props update?
|
||||
private isFillingDueToPropsUpdate = false;
|
||||
// Did another request to check the fill state arrive while we were trying to backfill?
|
||||
private fillRequestWhileRunning: boolean;
|
||||
private fillRequestWhileRunning = false;
|
||||
// Is that next fill request scheduled because of a props update?
|
||||
private pendingFillDueToPropsUpdate: boolean;
|
||||
private scrollState: IScrollState;
|
||||
private pendingFillDueToPropsUpdate = false;
|
||||
private scrollState!: IScrollState;
|
||||
private preventShrinkingState: IPreventShrinkingState | null = null;
|
||||
private unfillDebouncer: number | null = null;
|
||||
private bottomGrowth: number;
|
||||
private minListHeight: number;
|
||||
private heightUpdateInProgress: boolean;
|
||||
private bottomGrowth!: number;
|
||||
private minListHeight!: number;
|
||||
private heightUpdateInProgress = false;
|
||||
private divScroll: HTMLDivElement | null = null;
|
||||
|
||||
public constructor(props: IProps) {
|
||||
|
|
|
@ -28,7 +28,7 @@ interface IProps {
|
|||
}
|
||||
|
||||
interface IState {
|
||||
phase: Phase;
|
||||
phase?: Phase;
|
||||
lostKeys: boolean;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import classNames from "classnames";
|
|||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { ISSOFlow, LoginFlow, SSOAction } from "matrix-js-sdk/src/@types/auth";
|
||||
|
||||
import { _t, _td } from "../../../languageHandler";
|
||||
import { _t, _td, UserFriendlyError } from "../../../languageHandler";
|
||||
import Login from "../../../Login";
|
||||
import { messageForConnectionError, messageForLoginError } from "../../../utils/ErrorUtils";
|
||||
import AutoDiscoveryUtils from "../../../utils/AutoDiscoveryUtils";
|
||||
|
@ -110,7 +110,7 @@ type OnPasswordLogin = {
|
|||
*/
|
||||
export default class LoginComponent extends React.PureComponent<IProps, IState> {
|
||||
private unmounted = false;
|
||||
private loginLogic: Login;
|
||||
private loginLogic!: Login;
|
||||
|
||||
private readonly stepRendererMap: Record<string, () => ReactNode>;
|
||||
|
||||
|
@ -265,7 +265,7 @@ export default class LoginComponent extends React.PureComponent<IProps, IState>
|
|||
logger.error("Problem parsing URL or unhandled error doing .well-known discovery:", e);
|
||||
|
||||
let message = _t("Failed to perform homeserver discovery");
|
||||
if (e.translatedMessage) {
|
||||
if (e instanceof UserFriendlyError && e.translatedMessage) {
|
||||
message = e.translatedMessage;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ interface IProps {
|
|||
}
|
||||
|
||||
interface IState {
|
||||
phase: Phase;
|
||||
phase?: Phase;
|
||||
verificationRequest: VerificationRequest | null;
|
||||
backupInfo: IKeyBackupInfo | null;
|
||||
lostKeys: boolean;
|
||||
|
|
|
@ -18,6 +18,7 @@ import React, { ChangeEvent, SyntheticEvent } from "react";
|
|||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { Optional } from "matrix-events-sdk";
|
||||
import { ISSOFlow, LoginFlow, SSOAction } from "matrix-js-sdk/src/@types/auth";
|
||||
import { MatrixError } from "matrix-js-sdk/src/http-api";
|
||||
|
||||
import { _t } from "../../../languageHandler";
|
||||
import dis from "../../../dispatcher/dispatcher";
|
||||
|
@ -164,7 +165,11 @@ export default class SoftLogout extends React.Component<IProps, IState> {
|
|||
credentials = await sendLoginRequest(hsUrl, isUrl, loginType, loginParams);
|
||||
} catch (e) {
|
||||
let errorText = _t("Failed to re-authenticate due to a homeserver problem");
|
||||
if (e.errcode === "M_FORBIDDEN" && (e.httpStatus === 401 || e.httpStatus === 403)) {
|
||||
if (
|
||||
e instanceof MatrixError &&
|
||||
e.errcode === "M_FORBIDDEN" &&
|
||||
(e.httpStatus === 401 || e.httpStatus === 403)
|
||||
) {
|
||||
errorText = _t("Incorrect password");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue