kit icon indicating copy to clipboard operation
kit copied to clipboard

Expose Remote Form Submit Type

Open jdgamble555 opened this issue 1 month ago • 0 comments

Describe the problem

This is an extremely small issue, but I figured I would make an issue for it.

For form actions, you can expose the enhance form type like so:

import type { SubmitFunction } from '@sveltejs/kit';

const onSubmit: SubmitFunction<MyFormType> = async ({ formElement }) => {

But there is no SubmitFunction for Remote Functions.

Describe the proposed solution

const onSubmit: SubmitRemoteFunction<myForm> = async ({ submit }) => {

Alternatives considered

Just use the Parameters to derive it (this is the workaround for now):

type SubmitRemoteFunction = Parameters<typeof myForm.enhance>[0];

const onSubmit: SubmitRemoteFunction = async ({ submit }) => {
	try {
		await submit();
	} catch (error) {
		console.error(error);
	}
};

<form {...myForm.preflight(myFormSchema).enhance(onSubmit)}>

Importance

nice to have

Additional Information

Extremely small issue, but extremely easy to fix too.

jdgamble555 avatar Dec 07 '25 23:12 jdgamble555