Skip to content

fix: add null and undefined to RemoteFormInput type#15859

Open
PranavAgarkar07 wants to merge 1 commit into
sveltejs:mainfrom
PranavAgarkar07:fix/remote-form-nullable-types
Open

fix: add null and undefined to RemoteFormInput type#15859
PranavAgarkar07 wants to merge 1 commit into
sveltejs:mainfrom
PranavAgarkar07:fix/remote-form-nullable-types

Conversation

@PranavAgarkar07
Copy link
Copy Markdown

closes #15249

Goal

Remote form schemas using .nullable() (Zod) or equivalent null-producing validators fail TypeScript because RemoteFormInput's index signature does not include null or undefined in its value union. This means any schema whose inferred input type contains null (e.g. z.string().nullable()string | null) cannot satisfy the StandardSchemaV1<RemoteFormInput, ...> constraint on form().

What was changed

  • Added null and undefined to the MaybeArray<...> union inside the RemoteFormInput index signature in packages/kit/src/exports/public.d.ts
  • Regenerated packages/kit/types/index.d.ts via pnpm generate:types
  • Added a type-level regression test in packages/kit/test/types/remote.test.ts covering nullable fields (string | null, number | null)

Why this is the best fix

Minimal. One union member added to one line — the runtime already handles null (unchecked checkboxes produce null at form.svelte.js:494, proxy getters use ?? throughout). Both null and undefined are included because ZodNullish (.nullish()) produces both, and ZodOptional (.optional()) produces undefined — the same class of issue.

No runtime risk. The RemoteFormInput type is a compile-time constraint on generic parameters. It never appears in emitted code. Adding null | undefined widens the accepted schema types without changing any runtime behavior.

Community-validated. The issue reporter independently asked: "Would it be enough to allow null in the RemoteFormInput?" — confirming this approach before implementation.

Verification

  • pnpm check — TypeScript passes for both main types and test types
  • pnpm -F @sveltejs/kit test:unit — 537/537 tests pass
  • pnpm prepublishOnly — types regenerate cleanly (no unexpected diffs)
  • pnpm run lint — linting clean

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 17, 2026

🦋 Changeset detected

Latest commit: 0649017

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

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 Forms not handling null values

2 participants