Improve types (#11239)

This commit is contained in:
Michael Telatynski 2023-07-12 15:56:51 +01:00 committed by GitHub
parent 44615b2b04
commit f1534fda79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 35 additions and 42 deletions

View file

@ -345,12 +345,15 @@ export default class ForgotPassword extends React.Component<Props, State> {
}
};
private onInputChanged = (stateKey: string, ev: React.FormEvent<HTMLInputElement>): void => {
private onInputChanged = (
stateKey: "email" | "password" | "password2",
ev: React.FormEvent<HTMLInputElement>,
): void => {
let value = ev.currentTarget.value;
if (stateKey === "email") value = value.trim();
this.setState({
[stateKey]: value,
} as any);
} as Pick<State, typeof stateKey>);
};
public renderEnterEmail(): JSX.Element {

View file

@ -29,7 +29,7 @@ interface EnterEmailProps {
errorText: string | ReactNode | null;
homeserver: string;
loading: boolean;
onInputChanged: (stateKey: string, ev: React.FormEvent<HTMLInputElement>) => void;
onInputChanged: (stateKey: "email", ev: React.FormEvent<HTMLInputElement>) => void;
onLoginClick: () => void;
onSubmitForm: (ev: React.FormEvent) => void;
}