sveltejs / sveltejs/kit

`form.fields.set` should accept `Partial` data

Open
#15,328 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

forms types / typescript
Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the problem

I think it would make sense to be able to set partial data on form.fields. For example with this form:

export const editData = form(
	v.object({ name: v.string(), id: v.string(), confirmationName: v.string() }),
	async (data) => {
		// ...
	}
);

editData.fields.set({ name: "foo", id: "123" }) should then set name and id, and leave confirmationName alone. Today, TypeScript yells at me that confirmationName is missing.

Describe the proposed solution

form.fields.set should accept Partial<T> instead of T. Maybe also for nested fields, such as form.fields.my.nested.field.set?

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the type definitions and implementation for form.fields.set, then inspect how nested fields are typed. Done means a form with required fields accepts a Partial data object, preserves omitted fields, and the nested-field behavior is defined or covered as appropriate.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.