Skip to content

breaking: move remote function types to $app/server - #16740

Merged
teemingc merged 11 commits into
version-3from
server-types
Aug 11, 2026
Merged

breaking: move remote function types to $app/server#16740
teemingc merged 11 commits into
version-3from
server-types

Conversation

@Rich-Harris

Copy link
Copy Markdown
Member

another part of #16676


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.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Aug 11, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 715be9b:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/715be9b7598205ddbfe5c3cf5e664036d11a261c

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

@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 715be9b

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 Major

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

@teemingc

Copy link
Copy Markdown
Member

/autofix

@Nic-Polumeyv Nic-Polumeyv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The remote-functions docs snippets (~299, ~1060, ~1115) still import the moved types from @sveltejs/kit. And since ValidationError is moving: isValidationError has the wrong guard type:

* @return {e is import('$app/server').ValidationError}

Other then that, LGTM!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, trusting you to fix whatever CI errors occur

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Suggestions:

  1. isValidationError type guard narrows to the wrong type (ActionFailure) instead of ValidationError, giving callers an incorrectly-typed value.
  1. Doc snippets import remote function types (RemoteLiveQueryFunction, RemoteQueryUpdate, RemoteQuery, RemoteQueryFunction) from @sveltejs/kit, but this PR moved those types to $app/server, so the imports point to a module that no longer exports them.

Fix on Vercel

vercel Bot and others added 2 commits August 11, 2026 17:38
…nFailure`) instead of `ValidationError`, giving callers an incorrectly-typed value.

This commit fixes the issue reported at packages/kit/src/exports/index.js:276

## Bug

`isValidationError` is implemented as:

```js
export function isValidationError(e) {
	return e instanceof ValidationError;
}
```

It checks for `ValidationError` (the class thrown by `invalid()`, shape `{ issues: StandardSchemaV1.Issue[] }`), but its JSDoc declared the guard as:

```js
* @return {e is import('./public.js').ActionFailure}
```

`ActionFailure` is an unrelated type (`{ status, data }`). This is a real type-safety bug: any caller who uses this guard inside an `if (isValidationError(e))` block gets `e` narrowed to `ActionFailure`, so:

*   Accessing the actual runtime property `e.issues` is a type error.
*   `e.status` / `e.data` appear to exist at the type level even though the runtime object has neither.

The failure trigger is concrete: `if (isValidationError(err)) { err.issues }` fails to type-check, and `err.status` type-checks despite being `undefined` at runtime.

## Fix

Since this PR promotes `ValidationError` to a public type exported from `$app/server` (`packages/kit/src/runtime/app/server/public.d.ts`), the guard now references it:

```js
* @return {e is import('$app/server').ValidationError}
```

This cross-module reference pattern is already used elsewhere in the codebase (many runtime files reference `$app/server` types via JSDoc) and resolves via the tsconfig path alias.

I also regenerated the public type declarations with `pnpm generate:types`, updating `packages/kit/types/index.d.ts`:

```ts
export function isValidationError(e: unknown): e is import("$app/server").ValidationError;
```

Only the two intended lines changed (source JSDoc + generated `.d.ts`); the generated types file was not otherwise formatted.


Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: teemingc <chewteeming01@gmail.com>
…ion`, `RemoteQueryUpdate`, `RemoteQuery`, `RemoteQueryFunction`) from `@sveltejs/kit`, but this PR moved those types to `$app/server`, so the imports point to a module that no longer exports them.

This commit fixes the issue reported at documentation/docs/20-core-concepts/60-remote-functions.md:299

## Bug

This PR ("move remote function types to `$app/server`") relocated the remote function types out of the `@sveltejs/kit` module and into the `$app/server` module.

Verified against the current tree:

*   `packages/kit/src/exports/public.d.ts` (the `@sveltejs/kit` module) — **no longer** exports `RemoteLiveQueryFunction`, `RemoteQueryUpdate`, `RemoteQuery`, or `RemoteQueryFunction` (grep returns no matches).
*   `packages/kit/src/runtime/app/server/public.d.ts` (the `$app/server` module) — now exports all of them: `RemoteQueryUpdate` (line 352), `RemoteQuery` (line 377), `RemoteQueryFunction` (line 445), `RemoteLiveQueryFunction` (line 456).

Three documentation code snippets in `documentation/docs/20-core-concepts/60-remote-functions.md` were not updated and still import from `@sveltejs/kit`:

```ts
// line ~299
import { RemoteLiveQueryFunction } from '@sveltejs/kit';

// line ~1060
import type { RemoteQueryUpdate, RemoteQuery } from '@sveltejs/kit';

// line ~1115
import type { RemoteQueryFunction } from '@sveltejs/kit';
```

**Impact:** Users copying these examples would import types from a location where they no longer exist, resulting in TypeScript errors. The docs are also inconsistent with the PR's own updates to `packages/kit/test/types/remote.test.ts` and the test `+page.svelte` files, which were changed to import from `$app/server`.

## Fix

Changed all three import statements to import from `$app/server`. For the third snippet, the `RemoteQueryFunction` type import was merged into the existing `import { requested } from '$app/server';` line using an inline `type` modifier:

```ts
import { requested, type RemoteQueryFunction } from '$app/server';
```

The patch was regenerated to touch **only** the three import lines. The previous version of this patch contained an encoding regression that mangled an em-dash (`—`) into replacement characters (`����`) in the "`requested` gives you access..." paragraph; that unintended change has been removed, and all surrounding prose (including em-dashes) is preserved exactly.


Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: teemingc <chewteeming01@gmail.com>
@Nic-Polumeyv

Copy link
Copy Markdown
Contributor

Additional Suggestions:

1. `isValidationError` type guard narrows to the wrong type (`ActionFailure`) instead of `ValidationError`, giving callers an incorrectly-typed value.


2. Doc snippets import remote function types (`RemoteLiveQueryFunction`, `RemoteQueryUpdate`, `RemoteQuery`, `RemoteQueryFunction`) from `@sveltejs/kit`, but this PR moved those types to `$app/server`, so the imports point to a module that no longer exports them.

Fix on Vercel

Hey buddy, I found this first. Scram.

@teemingc
teemingc merged commit 1742811 into version-3 Aug 11, 2026
27 checks passed
@teemingc
teemingc deleted the server-types branch August 11, 2026 18:46
Rich-Harris pushed a commit that referenced this pull request Aug 11, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to version-3, this PR
will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

`version-3` is currently in **pre mode** so this branch has prereleases
rather than normal releases. If you want to exit prereleases, run
`changeset pre exit` on `version-3`.

⚠️⚠️⚠️⚠️⚠️⚠️

# Releases
## @sveltejs/kit@3.0.0-next.20

### Major Changes

- breaking: move remote function types to `$app/server`
([#16740](#16740))

- breaking: remove `#lib` definition from `paths`; requires explicit
module extensions as a result
([#16736](#16736))

- breaking: move hooks-related types to `@sveltejs/kit/hooks`
([#16737](#16737))

- breaking: move env-related types to `@sveltejs/kit/env`
([#16739](#16739))

### Minor Changes

- feat: better response logging
([#16744](#16744))

### Patch Changes

- chore: bump `mrmime` to 2.0.1
([#16745](#16745))

- chore: bump `@sveltejs/acorn-typescript` to 1.0.12
([#16745](#16745))

- chore: bump `magic-string` to 1.1.0
([#16745](#16745))

- chore: bump `devalue` to 5.9.0
([#16745](#16745))

- chore: bump `cookie` to 2.0.1
([#16745](#16745))

- chore: bump `acorn` to 8.18.0
([#16745](#16745))

- fix: avoid infinite loop when building with `--watch` flag
([#16632](#16632))
## @sveltejs/adapter-cloudflare@8.0.0-next.6

### Patch Changes

- chore: bump `@cloudflare/worker-types` to 5.20260809.1
([#16745](#16745))
- Updated dependencies
[[`1742811`](1742811),
[`1611c61`](1611c61),
[`b361b81`](b361b81),
[`b361b81`](b361b81),
[`b361b81`](b361b81),
[`b361b81`](b361b81),
[`13e7b18`](13e7b18),
[`529346d`](529346d),
[`b361b81`](b361b81),
[`81d6319`](81d6319),
[`b361b81`](b361b81),
[`69a5bdf`](69a5bdf)]:
  - @sveltejs/kit@3.0.0-next.20
## @sveltejs/adapter-netlify@7.0.0-next.8

### Patch Changes

- chore: bump `rolldown` to 1.2.3
([#16745](#16745))
- Updated dependencies
[[`1742811`](1742811),
[`1611c61`](1611c61),
[`b361b81`](b361b81),
[`b361b81`](b361b81),
[`b361b81`](b361b81),
[`b361b81`](b361b81),
[`13e7b18`](13e7b18),
[`529346d`](529346d),
[`b361b81`](b361b81),
[`81d6319`](81d6319),
[`b361b81`](b361b81),
[`69a5bdf`](69a5bdf)]:
  - @sveltejs/kit@3.0.0-next.20
## @sveltejs/adapter-node@6.0.0-next.10

### Patch Changes

- chore: bump `rolldown` to 1.2.3
([#16745](#16745))
- Updated dependencies
[[`1742811`](1742811),
[`1611c61`](1611c61),
[`b361b81`](b361b81),
[`b361b81`](b361b81),
[`b361b81`](b361b81),
[`b361b81`](b361b81),
[`13e7b18`](13e7b18),
[`529346d`](529346d),
[`b361b81`](b361b81),
[`81d6319`](81d6319),
[`b361b81`](b361b81),
[`69a5bdf`](69a5bdf)]:
  - @sveltejs/kit@3.0.0-next.20
## @sveltejs/enhanced-img@1.0.0-next.5

### Patch Changes

- chore: bump `magic-string` to 1.1.0
([#16745](#16745))

- chore: bump `zimmerframe` to 1.1.4
([#16745](#16745))
## @sveltejs/package@3.0.0-next.6

### Patch Changes

- chore: bump `svelte2tsx` to 0.7.59
([#16745](#16745))

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Rich-Harris added a commit that referenced this pull request Aug 12, 2026
…ltejs/kit/remote` (#16764)

Moves the remote function types from `$app/server` to a new
`@sveltejs/kit/remote` module, same shape as `/hooks` and `/env`.
`isValidationError` moves there too, next to `ValidationError`.
Follow-up to #16740.

---

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

- [x] 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
- [x] This message body should clearly illustrate what problems it
solves.
- [ ] Ideally, include a test that fails without this PR but passes with
it.

### Tests

- [x] Run the tests with `pnpm test` and lint the project with `pnpm
lint` and `pnpm check`

### Changesets

- [x] 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

- [x] Please ensure that 'Allow edits from maintainers' is checked. PRs
without this option may be closed.

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants