Skip to content

breaking: move hooks-related types to @sveltejs/kit/hooks - #16737

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

breaking: move hooks-related types to @sveltejs/kit/hooks#16737
teemingc merged 26 commits into
version-3from
hooks-types

Conversation

@Rich-Harris

Copy link
Copy Markdown
Member

Another part of #16676. @dummdidumm will this need changes to the auto-injected types?

The diff is larger than it needs to be, presumably because of formatting-related changes after switching to oxfmt


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 313ab71:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/313ab712bafeebd864971bb7fd4d57d5839a3ab8

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

@changeset-bot

changeset-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 313ab71

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

@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 Suggestion:

Multiple .js files reference Handle/ResolveOptions/Transport/CaughtError/HandleServerError/ClientCaughtError from @sveltejs/kit, but those types were moved to @sveltejs/kit/hooks, breaking pnpm check (checkJs).

Fix on Vercel

vercel Bot and others added 2 commits August 11, 2026 15:58
…ort`/`CaughtError`/`HandleServerError`/`ClientCaughtError` from `@sveltejs/kit`, but those types were moved to `@sveltejs/kit/hooks`, breaking `pnpm check` (checkJs).

This commit fixes the issue reported at packages/kit/src/exports/hooks/sequence.js:1

## The bug

This PR moved several public types out of `packages/kit/src/exports/public.d.ts` and into `packages/kit/src/exports/hooks/public.d.ts`.

Verified in the current tree:

*   `grep` for `Handle|ResolveOptions|Transport|CaughtError|HandleServerError|ClientCaughtError` in `src/exports/public.d.ts` → **no matches** (removed).
*   They now live in `src/exports/hooks/public.d.ts`:
    *   `Handle` (13), `CaughtError` (37), `ClientCaughtError` (53), `HandleServerError` (69), `Transport` (151), `ResolveOptions` (164).
*   `public.d.ts` does **not** re-export the hooks module (`export * from './index.js'` at line 2049, not from `./hooks`), so these members are no longer reachable via `@sveltejs/kit`.
*   `RequestEvent` (public.d.ts:1197) and `ServerInitOptions` (public.d.ts:1349) were **not** moved and correctly stay on `@sveltejs/kit`.

Because `packages/kit/tsconfig.json` maps `@sveltejs/kit` → `./src/exports/public.d.ts` with `checkJs: true`, every JSDoc reference to a moved type produces a concrete compile error (`TS2305` for `@import`, `TS2694` for inline `import('...').X`), so `pnpm check` fails.

### Affected references (all confirmed present)

*   `src/exports/hooks/sequence.js:1` — `@import { Handle, RequestEvent, ResolveOptions }`
*   `src/runtime/app/internal/transport.js:1` — `@import { Transport }`
*   `src/runtime/server/respond.js:579` — `import('@sveltejs/kit').ResolveOptions`
*   `src/runtime/server/page/load_data.js:263` — `import('@sveltejs/kit').ResolveOptions`
*   `src/runtime/server/errors.js:51` — `import('@sveltejs/kit').CaughtError`
*   `src/runtime/server/errors.js:80` — `import('@sveltejs/kit').HandleServerError`
*   `src/runtime/client/client.js:2521` — `import('@sveltejs/kit').ClientCaughtError`

## The fix

1.  Added a `@sveltejs/kit/hooks` → `./src/exports/hooks/public.d.ts` mapping to `tsconfig.json` `paths` (the `./hooks` subpath already exists in `package.json`, but the path-mapping used by `check` lacked it).
2.  Repointed every moved-type reference above to `@sveltejs/kit/hooks`, keeping `RequestEvent` on `@sveltejs/kit`.
3.  Also updated the two `/// type: import('@sveltejs/kit').Handle` annotations in `sequence.js`'s JSDoc example (lines 21/40) so the rendered docs show the correct import location. Left `ServerInitOptions` (server/index.js:86) untouched since it did not move.

## Verification note

`pnpm check` could not be executed here: the sandbox lacks the `@typescript/native` tsc binary and `node_modules` are out of sync (no `tsc` available anywhere). The resolution is deterministic and each type is restored to a module that actually exports it.


Co-authored-by: Vercel <vercel[bot]@users.noreply.github.com>
Co-authored-by: Rich-Harris <hello@rich-harris.dev>
@teemingc

Copy link
Copy Markdown
Member

/autofix

@dummdidumm

Copy link
Copy Markdown
Member

yes needs changes to language tools, I can check that part

Comment thread packages/kit/src/exports/hooks/public.d.ts Outdated

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.

🔥

Nic-Polumeyv

This comment was marked as outdated.

Comment thread packages/kit/src/types/internal.d.ts
vercel Bot and others added 2 commits August 11, 2026 19:00
…eLiveQuery` imported twice in `internal.d.ts` — once from `@sveltejs/kit` (where they no longer exist) and once from `$app/server`.

This commit fixes the issue reported at packages/kit/src/types/internal.d.ts:18

## Bug

In `packages/kit/src/types/internal.d.ts`, the version-3 merge moved the remote-function types (`RemoteFormIssue`, `RemoteQuery`, `RemoteLiveQuery`) out of `@sveltejs/kit` and into `$app/server`, but the merge resolution left the old import in place while also adding the new one:

```ts
import {
	...
	Emulator,
	RemoteFormIssue,
	RemoteQuery,
	RemoteLiveQuery
} from '@sveltejs/kit';
import { RemoteFormIssue, RemoteQuery, RemoteLiveQuery } from '$app/server';
```

This produces two distinct TypeScript errors:

1. **TS2305 "has no exported member"** — I verified these three identifiers are no longer exported from `@sveltejs/kit` (`grep` in `src/exports/public.d.ts` returns no matches).
2. **TS2300 "Duplicate identifier"** — the same three names are imported in both statements.

They *are* now defined/exported from `$app/server` (`src/runtime/app/server/public.d.ts`, e.g. `export interface RemoteFormIssue`, `export type RemoteQuery<T>`, `export type RemoteLiveQuery<T>`), confirming the `$app/server` import is the correct one.

This would break `pnpm check`.

## Fix

Removed `RemoteFormIssue`, `RemoteQuery`, and `RemoteLiveQuery` from the `@sveltejs/kit` import block (and cleaned up the trailing comma after `Emulator`), leaving the `$app/server` import as the sole source of these types.

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

Copy link
Copy Markdown
Member

/autofix

@teemingc
teemingc merged commit 529346d into version-3 Aug 11, 2026
27 checks passed
@teemingc
teemingc deleted the hooks-types branch August 11, 2026 19:44
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>
dummdidumm added a commit to sveltejs/language-tools that referenced this pull request Aug 12, 2026
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.

5 participants