mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-08 01:45:28 +00:00
remove most uses of as any in typescript
- replaced many uses of `as any` with another more specific cast `as T` - filled in missing typed for items that needed to be typed - new runtime code was added where necessary to satisfy the new types with comments - added missing theme variable "sidebar-active" to the Theme variables - forms using `react-hook-form` are now typechecked - changed some instances of `target` into `currentTarget` while removing `as any` assertions
This commit is contained in:
@@ -35,6 +35,12 @@ function getInviteCode() {
|
||||
return code ?? '';
|
||||
}
|
||||
|
||||
interface FormInputs {
|
||||
email: string
|
||||
password: string
|
||||
invite: string
|
||||
}
|
||||
|
||||
export function Form({ page, callback }: Props) {
|
||||
const client = useContext(AppContext);
|
||||
|
||||
@@ -43,7 +49,7 @@ export function Form({ page, callback }: Props) {
|
||||
const [error, setGlobalError] = useState<string | undefined>(undefined);
|
||||
const [captcha, setCaptcha] = useState<CaptchaProps | undefined>(undefined);
|
||||
|
||||
const { handleSubmit, register, errors, setError } = useForm({
|
||||
const { handleSubmit, register, errors, setError } = useForm<FormInputs>({
|
||||
defaultValues: {
|
||||
email: '',
|
||||
password: '',
|
||||
@@ -51,11 +57,7 @@ export function Form({ page, callback }: Props) {
|
||||
}
|
||||
});
|
||||
|
||||
async function onSubmit(data: {
|
||||
email: string;
|
||||
password: string;
|
||||
invite: string;
|
||||
}) {
|
||||
async function onSubmit(data: FormInputs) {
|
||||
setGlobalError(undefined);
|
||||
setLoading(true);
|
||||
|
||||
@@ -143,7 +145,8 @@ export function Form({ page, callback }: Props) {
|
||||
return (
|
||||
<div className={styles.form}>
|
||||
<img src={wideSVG} />
|
||||
<form onSubmit={handleSubmit(onSubmit) as any}>
|
||||
{/* Preact / React typing incompatabilities */}
|
||||
<form onSubmit={handleSubmit(onSubmit) as JSX.GenericEventHandler<HTMLFormElement>}>
|
||||
{page !== "reset" && (
|
||||
<FormField
|
||||
type="email"
|
||||
|
||||
Reference in New Issue
Block a user