fix: add null and undefined to RemoteFormInput type#15859
Open
PranavAgarkar07 wants to merge 1 commit into
Open
fix: add null and undefined to RemoteFormInput type#15859PranavAgarkar07 wants to merge 1 commit into
null and undefined to RemoteFormInput type#15859PranavAgarkar07 wants to merge 1 commit into
Conversation
…nullable/optional schemas
🦋 Changeset detectedLatest commit: 0649017 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #15249
Goal
Remote form schemas using
.nullable()(Zod) or equivalentnull-producing validators fail TypeScript becauseRemoteFormInput's index signature does not includenullorundefinedin its value union. This means any schema whose inferred input type containsnull(e.g.z.string().nullable()→string | null) cannot satisfy theStandardSchemaV1<RemoteFormInput, ...>constraint onform().What was changed
nullandundefinedto theMaybeArray<...>union inside theRemoteFormInputindex signature inpackages/kit/src/exports/public.d.tspackages/kit/types/index.d.tsviapnpm generate:typespackages/kit/test/types/remote.test.tscovering 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 producenullatform.svelte.js:494, proxy getters use??throughout). Bothnullandundefinedare included becauseZodNullish(.nullish()) produces both, andZodOptional(.optional()) producesundefined— the same class of issue.No runtime risk. The
RemoteFormInputtype is a compile-time constraint on generic parameters. It never appears in emitted code. Addingnull | undefinedwidens 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 typespnpm -F @sveltejs/kit test:unit— 537/537 tests passpnpm prepublishOnly— types regenerate cleanly (no unexpected diffs)pnpm run lint— linting cleanPlease don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits