breaking: `invalid` now must be imported from `@sveltejs/kit` (#14768)
authorSimon H <5968653+dummdidumm@users.noreply.github.com>
Thu, 20 Nov 2025 21:31:29 +0000 (22:31 +0100)
committerGitHub <noreply@github.com>
Thu, 20 Nov 2025 21:31:29 +0000 (16:31 -0500)
commitbd55128f69fc8d3f74f7be58416180660fb42d3e
treecbe0be83d196a206d1d58d07e94019ac3e4f0812
parentaf6bb83e9db13187fa2363eca1ab53e32b1f0021
breaking: `invalid` now must be imported from `@sveltejs/kit` (#14768)

* breaking: `invalid` now must be imported from `@sveltejs/kit`

TypeScript kinda forced our hand here - due to limitations of control flow analysis it does not detect the `never` return type for anything else than functions that are used directly (i.e. passing a function as a parameter doesn't work unless you explicitly type it); see https://github.com/microsoft/TypeScript/issues/36753 for more info.

This therefore changes `invalid` to be a function that you import just like `redirect` or `error`. A nice benefit of this is that you'll no longer have to use the second parameter passed to remote form functions to construct the list of issues in case you want to create an issue for the whole form and not just a specific field.

Closes #14745

* docs

* fix test

* Apply suggestions from code review

* Update packages/kit/src/runtime/app/server/remote/form.js

* Update documentation/docs/20-core-concepts/60-remote-functions.md

* prettier

* regenerate

* fix

---------

Co-authored-by: Rich Harris <richard.a.harris@gmail.com>
Co-authored-by: Rich Harris <rich.harris@vercel.com>
.changeset/icy-glasses-agree.md [new file with mode: 0644]
documentation/docs/20-core-concepts/60-remote-functions.md
packages/kit/src/exports/index.js
packages/kit/src/exports/internal/index.js
packages/kit/src/exports/public.d.ts
packages/kit/src/runtime/app/server/remote/form.js
packages/kit/test/apps/basics/src/routes/remote/form/validate/form.remote.ts
packages/kit/test/types/remote.test.ts
packages/kit/types/index.d.ts