Conform more of the codebase to strictNullChecks (#10350

* Conform more of the codebase to `strictNullChecks`

* Iterate

* Generics ftw

* Iterate
This commit is contained in:
Michael Telatynski 2023-03-10 14:55:06 +00:00 committed by GitHub
parent d53e91802d
commit 127a3b667c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
53 changed files with 279 additions and 263 deletions

View file

@ -395,7 +395,7 @@ export default class ForgotPassword extends React.Component<Props, State> {
button: _t("Continue"),
});
const [confirmed] = await finished;
return confirmed;
return !!confirmed;
}
public renderCheckEmail(): JSX.Element {

View file

@ -368,7 +368,7 @@ export default class LoginComponent extends React.PureComponent<IProps, IState>
isDefaultServer = true;
}
const fallbackHsUrl = isDefaultServer ? this.props.fallbackHsUrl : null;
const fallbackHsUrl = isDefaultServer ? this.props.fallbackHsUrl! : null;
const loginLogic = new Login(hsUrl, isUrl, fallbackHsUrl, {
defaultDeviceDisplayName: this.props.defaultDeviceDisplayName,
@ -514,7 +514,7 @@ export default class LoginComponent extends React.PureComponent<IProps, IState>
// this is the ideal order we want to show the flows in
const order = ["m.login.password", "m.login.sso"];
const flows = filterBoolean(order.map((type) => this.state.flows.find((flow) => flow.type === type)));
const flows = filterBoolean(order.map((type) => this.state.flows?.find((flow) => flow.type === type)));
return (
<React.Fragment>
{flows.map((flow) => {
@ -546,7 +546,7 @@ export default class LoginComponent extends React.PureComponent<IProps, IState>
};
private renderSsoStep = (loginType: "cas" | "sso"): JSX.Element => {
const flow = this.state.flows.find((flow) => flow.type === "m.login." + loginType) as ISSOFlow;
const flow = this.state.flows?.find((flow) => flow.type === "m.login." + loginType) as ISSOFlow;
return (
<SSOButtons
@ -554,7 +554,7 @@ export default class LoginComponent extends React.PureComponent<IProps, IState>
flow={flow}
loginType={loginType}
fragmentAfterLogin={this.props.fragmentAfterLogin}
primary={!this.state.flows.find((flow) => flow.type === "m.login.password")}
primary={!this.state.flows?.find((flow) => flow.type === "m.login.password")}
action={SSOAction.LOGIN}
/>
);

View file

@ -88,7 +88,7 @@ export default class SetupEncryptionBody extends React.Component<IProps, IState>
private onVerifyClick = (): void => {
const cli = MatrixClientPeg.get();
const userId = cli.getUserId();
const userId = cli.getSafeUserId();
const requestPromise = cli.requestVerification(userId);
// We need to call onFinished now to close this dialog, and
@ -212,7 +212,7 @@ export default class SetupEncryptionBody extends React.Component<IProps, IState>
{useRecoveryKeyButton}
</div>
<div className="mx_SetupEncryptionBody_reset">
{_t("Forgotten or lost all recovery methods? <a>Reset all</a>", null, {
{_t("Forgotten or lost all recovery methods? <a>Reset all</a>", undefined, {
a: (sub) => (
<AccessibleButton
kind="link_inline"
@ -228,7 +228,7 @@ export default class SetupEncryptionBody extends React.Component<IProps, IState>
);
}
} else if (phase === Phase.Done) {
let message;
let message: JSX.Element;
if (this.state.backupInfo) {
message = (
<p>

View file

@ -23,7 +23,7 @@ import { _t } from "../../../languageHandler";
import dis from "../../../dispatcher/dispatcher";
import * as Lifecycle from "../../../Lifecycle";
import Modal from "../../../Modal";
import { MatrixClientPeg } from "../../../MatrixClientPeg";
import { IMatrixClientCreds, MatrixClientPeg } from "../../../MatrixClientPeg";
import { sendLoginRequest } from "../../../Login";
import AuthPage from "../../views/auth/AuthPage";
import { SSO_HOMESERVER_URL_KEY, SSO_ID_SERVER_URL_KEY } from "../../../BasePlatform";
@ -159,7 +159,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
device_id: MatrixClientPeg.get().getDeviceId(),
};
let credentials = null;
let credentials: IMatrixClientCreds;
try {
credentials = await sendLoginRequest(hsUrl, isUrl, loginType, loginParams);
} catch (e) {
@ -192,7 +192,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
device_id: MatrixClientPeg.get().getDeviceId(),
};
let credentials = null;
let credentials: IMatrixClientCreds;
try {
credentials = await sendLoginRequest(hsUrl, isUrl, loginType, loginParams);
} catch (e) {
@ -212,7 +212,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
}
private renderPasswordForm(introText: Optional<string>): JSX.Element {
let error: JSX.Element = null;
let error: JSX.Element | undefined;
if (this.state.errorText) {
error = <span className="mx_Login_error">{this.state.errorText}</span>;
}
@ -267,7 +267,7 @@ export default class SoftLogout extends React.Component<IProps, IState> {
return <Spinner />;
}
let introText = null; // null is translated to something area specific in this function
let introText: string | null = null; // null is translated to something area specific in this function
if (this.state.keyBackupNeeded) {
introText = _t(
"Regain access to your account and recover encryption keys stored in this session. " +

View file

@ -27,7 +27,7 @@ interface Props {
export function AuthHeaderDisplay({ title, icon, serverPicker, children }: PropsWithChildren<Props>): JSX.Element {
const context = useContext(AuthHeaderContext);
if (!context) {
return null;
return <></>;
}
const current = context.state.length ? context.state[0] : null;
return (