Make more of the codebase conform to strict types (#10857)

This commit is contained in:
Michael Telatynski 2023-05-16 14:25:43 +01:00 committed by GitHub
parent 7f017a84c2
commit 6a3f59cc76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
45 changed files with 127 additions and 121 deletions

View file

@ -28,7 +28,7 @@ interface IProps {
}
interface IState {
phase: Phase;
phase?: Phase;
lostKeys: boolean;
}

View file

@ -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;
}

View file

@ -38,7 +38,7 @@ interface IProps {
}
interface IState {
phase: Phase;
phase?: Phase;
verificationRequest: VerificationRequest | null;
backupInfo: IKeyBackupInfo | null;
lostKeys: boolean;

View file

@ -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");
}