Skip to content

Commit

Permalink
fix: onSubmitSuccess types
Browse files Browse the repository at this point in the history
  • Loading branch information
airjp73 committed Jul 24, 2024
1 parent 44d0724 commit 5b5803f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
8 changes: 3 additions & 5 deletions packages/remix/src/ValidatedForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type ValidatedFormProps<
FormInputData extends FieldValues,
FormOutputData,
FormResponseData,
> = RemixFormOpts<FormInputData, FormOutputData, FormResponseData> &
> = RemixFormOpts<FormInputData, FormOutputData> &
Omit<React.ComponentProps<"form">, "children"> & {
/**
* A ref to the form element.
Expand Down Expand Up @@ -51,7 +51,7 @@ export const ValidatedForm = <
reloadDocument,
...rest
}: ValidatedFormProps<FormInputData, FormOutputData, FormResponseData>) => {
const rvf = useForm<FormInputData, FormOutputData, FormResponseData>({
const rvf = useForm<FormInputData, FormOutputData>({
action,
id,
disableFocusOnError,
Expand All @@ -74,9 +74,7 @@ export const ValidatedForm = <
reloadDocument,
defaultValues,
fetcher,
} satisfies AllProps<
RemixFormOpts<FormInputData, FormOutputData, FormResponseData>
>);
} satisfies AllProps<RemixFormOpts<FormInputData, FormOutputData>>);

return (
<FormProvider scope={rvf.scope()}>
Expand Down
1 change: 0 additions & 1 deletion packages/remix/src/test/submission.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ it("should have the correct type for handleSubmit", async () => {
validator: validator as Validator<{ foo: string }>,
handleSubmit: async (data) => {
expectTypeOf(data).toEqualTypeOf<{ foo: string }>();
return {};
},
});
return (
Expand Down
15 changes: 5 additions & 10 deletions packages/remix/src/useForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ type FormSubmitOpts<FormOutputData, ResponseData> =
export type RemixFormOpts<
FormInputData extends FieldValues,
FormOutputData,
FormResponseData,
> = Omit<
FormOpts<FormInputData, FormOutputData, FormResponseData>,
FormOpts<FormInputData, FormOutputData, void>,
| keyof SubmitOptions
| "serverValidationErrors"
| "handleSubmit"
Expand All @@ -55,19 +54,15 @@ export type RemixFormOpts<
| "preventScrollReset"
| "relative"
> &
FormSubmitOpts<FormOutputData, FormResponseData> & {
FormSubmitOpts<FormOutputData, void> & {
fetcher?: FetcherWithComponents<unknown>;
};

/**
* Create and use an `FormScope`.
*/
export function useForm<
FormInputData extends FieldValues,
FormOutputData,
FormResponseData,
>(
rvfOpts: RemixFormOpts<FormInputData, FormOutputData, FormResponseData>,
export function useForm<FormInputData extends FieldValues, FormOutputData>(
rvfOpts: RemixFormOpts<FormInputData, FormOutputData>,
): FormApi<FormInputData> {
let rvf: FormApi<FormInputData>;

Expand Down Expand Up @@ -146,7 +141,7 @@ export function useForm<
});
};

rvf = useFormReact<FormInputData, FormOutputData, FormResponseData>({
rvf = useFormReact<FormInputData, FormOutputData, void>({
...rvfOpts,
...serverStuff,
otherFormProps: {
Expand Down

0 comments on commit 5b5803f

Please sign in to comment.