Make more code conform to strict null checks (#10219
* Make more code conform to strict null checks * Fix types * Fix tests * Fix remaining test assertions * Iterate PR
This commit is contained in:
parent
4c79ecf141
commit
76b82b4b2b
130 changed files with 603 additions and 603 deletions
|
@ -42,12 +42,12 @@ enum Phase {
|
|||
}
|
||||
|
||||
interface IProps {
|
||||
onFinished?: (outcome: {
|
||||
onFinished: (outcome: {
|
||||
didSetEmail?: boolean;
|
||||
/** Was one or more other devices logged out whilst changing the password */
|
||||
didLogoutOutOtherDevices: boolean;
|
||||
}) => void;
|
||||
onError?: (error: { error: string }) => void;
|
||||
onError: (error: { error: string }) => void;
|
||||
rowClassName?: string;
|
||||
buttonClassName?: string;
|
||||
buttonKind?: string;
|
||||
|
@ -68,9 +68,9 @@ interface IState {
|
|||
}
|
||||
|
||||
export default class ChangePassword extends React.Component<IProps, IState> {
|
||||
private [FIELD_OLD_PASSWORD]: Field;
|
||||
private [FIELD_NEW_PASSWORD]: Field;
|
||||
private [FIELD_NEW_PASSWORD_CONFIRM]: Field;
|
||||
private [FIELD_OLD_PASSWORD]: Field | null;
|
||||
private [FIELD_NEW_PASSWORD]: Field | null;
|
||||
private [FIELD_NEW_PASSWORD_CONFIRM]: Field | null;
|
||||
|
||||
public static defaultProps: Partial<IProps> = {
|
||||
onFinished() {},
|
||||
|
@ -154,7 +154,7 @@ export default class ChangePassword extends React.Component<IProps, IState> {
|
|||
},
|
||||
// TODO: Remove `user` once servers support proper UIA
|
||||
// See https://github.com/matrix-org/synapse/issues/5665
|
||||
user: cli.credentials.userId,
|
||||
user: cli.credentials.userId ?? undefined,
|
||||
password: oldPassword,
|
||||
};
|
||||
|
||||
|
@ -195,7 +195,7 @@ export default class ChangePassword extends React.Component<IProps, IState> {
|
|||
});
|
||||
}
|
||||
|
||||
private checkPassword(oldPass: string, newPass: string, confirmPass: string): { error: string } {
|
||||
private checkPassword(oldPass: string, newPass: string, confirmPass: string): { error: string } | undefined {
|
||||
if (newPass !== confirmPass) {
|
||||
return {
|
||||
error: _t("New passwords don't match"),
|
||||
|
@ -226,7 +226,7 @@ export default class ChangePassword extends React.Component<IProps, IState> {
|
|||
);
|
||||
};
|
||||
|
||||
private markFieldValid(fieldID: FieldType, valid: boolean): void {
|
||||
private markFieldValid(fieldID: FieldType, valid?: boolean): void {
|
||||
const { fieldValid } = this.state;
|
||||
fieldValid[fieldID] = valid;
|
||||
this.setState({
|
||||
|
@ -367,7 +367,7 @@ export default class ChangePassword extends React.Component<IProps, IState> {
|
|||
return Object.values(this.state.fieldValid).every(Boolean);
|
||||
}
|
||||
|
||||
private findFirstInvalidField(fieldIDs: FieldType[]): Field {
|
||||
private findFirstInvalidField(fieldIDs: FieldType[]): Field | null {
|
||||
for (const fieldID of fieldIDs) {
|
||||
if (!this.state.fieldValid[fieldID] && this[fieldID]) {
|
||||
return this[fieldID];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue