Skip to content

The remote form object's field method breaks when handling optional values in the schema #14461

@cnolte

Description

@cnolte

Describe the bug

When there is an optional value in the schema for a form remote function, the field method of the remote function has the following types: field<any>(string: any). So we loose type safety.

Reproduction

<form {...demo}>
	<input name={demo.field('demo')} /> <!-- Loose type safety -->
	<button type="submit">Demo submit</button>
</form>
export const demo = form(
	z.object({
		demo: z.string().optional()
	}),
	(data) => {
		console.log(data);
	}
);

Logs

System Info

-

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions