Skip to content

Expose Remote Form Submit Type #15038

@jdgamble555

Description

@jdgamble555

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions