Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/mighty-walls-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: add type for `form.issues.$`, make `form.issues` and `form.input` partial
6 changes: 4 additions & 2 deletions packages/kit/src/exports/public.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1943,9 +1943,11 @@ export type RemoteForm<Input extends RemoteFormInput | void, Output> = {
/** The number of pending submissions */
get pending(): number;
/** The submitted values */
input: null | UnionToIntersection<FlattenInput<Input, ''>>;
input: null | Partial<UnionToIntersection<FlattenInput<Input, ''>>>;
Copy link
Member

@teemingc teemingc Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one's a little trickier. It's either {} before submission or it contains all the fields after submission UnionToIntersection<FlattenInput<Input, ''>>. It cannot be a Partial where each property can be undefined independently.

Maybe it's worth using this utility type https://stackoverflow.com/questions/70459727/how-to-define-all-or-nothing-type to get a more accurate type.

type AllOrNothing<T extends any> = T | Partial<Record<keyof T, never>>;

Similarly for the issues property which is either an empty object or the intended type. Are they ever null? @dummdidumm @Rich-Harris

/** Validation issues */
issues: null | UnionToIntersection<FlattenIssues<Input, ''>>;
issues:
| null
| (Partial<UnionToIntersection<FlattenIssues<Input, ''>>> & { $?: RemoteFormIssue[] });
/** Spread this onto a `<button>` or `<input type="submit">` */
buttonProps: {
type: 'submit';
Expand Down
6 changes: 4 additions & 2 deletions packages/kit/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1919,9 +1919,11 @@ declare module '@sveltejs/kit' {
/** The number of pending submissions */
get pending(): number;
/** The submitted values */
input: null | UnionToIntersection<FlattenInput<Input, ''>>;
input: null | Partial<UnionToIntersection<FlattenInput<Input, ''>>>;
/** Validation issues */
issues: null | UnionToIntersection<FlattenIssues<Input, ''>>;
issues:
| null
| (Partial<UnionToIntersection<FlattenIssues<Input, ''>>> & { $?: RemoteFormIssue[] });
/** Spread this onto a `<button>` or `<input type="submit">` */
buttonProps: {
type: 'submit';
Expand Down
Loading