Skip to content

fix: widen remote form field types - #16937

Merged
teemingc merged 4 commits into
version-3from
elliott/remote-form-type-widening
Aug 26, 2026
Merged

fix: widen remote form field types#16937
teemingc merged 4 commits into
version-3from
elliott/remote-form-type-widening

Conversation

@elliott-with-the-longest-name-on-github

Copy link
Copy Markdown
Contributor

closes #16931

Union fields

Given a schema like { a: string } | { b: string }, form.fields was typed as { a: RemoteFormField<string> } | { b: RemoteFormField<string> }. That meant neither form.fields.a nor form.fields.b could be accessed, even though both fields exist on the runtime proxy:

const f = form(schema, () => {});

f.fields.a.as('text'); // error
f.fields.b.as('text'); // error

This preserves the original input union in a tuple so the outer conditional does not distribute over it, then deliberately collects the keys from every union member for the form instance. The container methods still use the original union, while the instance exposes both a and b; unknown fields remain errors.

Enum fields

A string enum field kept its literal union in the attributes returned by .as(...), which made an otherwise valid spread fail type checking:

<input {...form.fields.choice.as('text', 'one')} />

This widens literal strings to string only in the returned DOM-facing value property. The .as(...) arguments still use the original enum, so choice.as('text', 'three') remains an error for a 'one' | 'two' field.

Both cases have focused type regression tests.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Aug 25, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 8e0ee5e:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/8e0ee5ec6ff170476c515959c78bbad43f9c1958

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/16937

@changeset-bot

changeset-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8e0ee5e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@svelte-docs-bot

Copy link
Copy Markdown

Comment thread packages/kit/src/runtime/app/server/public.d.ts
@teemingc
teemingc merged commit 9a2b9ba into version-3 Aug 26, 2026
40 checks passed
@teemingc
teemingc deleted the elliott/remote-form-type-widening branch August 26, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remote function form type-checking does not work with union

2 participants