sv-utils: generate the supported Handle import for Kit 2

オープン 初心者向け
#1,404 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 4 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
85/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
typescript
領域
cli, tooling

調査の方向性

packages/sv-utils/src/tooling/js/kit.ts の addHooksHandle から始め、生成される TypeScript の import と JSDoc アノテーションの両方を確認してください。プロジェクトの通常のチェック、または issue に記載されている簡略化した型チェックを、サポート対象のすべての Kit メジャーバージョンで実行してください。生成された hook が有効な Handle エクスポートを使用し、両方の形式で型チェックが通れば完了です。

索引モデルが issue の本文から書いたものです。

説明

pkg:add

Summary

Adding Better Auth to a supported SvelteKit 2 project emits Handle imports from @sveltejs/kit/hooks. Kit 2 declares that type in @sveltejs/kit and does not export it from the hooks module. The generated hook fails type checking independently of the default Kit 3/Better Auth peer conflict.

Steps to reproduce

Start with a working TypeScript SvelteKit 2.70.3 project and use sv 1.0.1 to add the integrations:

npx --yes [email protected] add drizzle=database:sqlite+client:libsql better-auth=demo:password --no-install --no-git-check

Inspect src/hooks.server.ts. The generated import is:

import type { Handle } from '@sveltejs/kit/hooks';

Run the project's normal check. A minimized type check with the published Kit 2.70.3 declarations and TypeScript 6.0.3 also reproduces the error using only this import and export type ConsumerHandle = Handle.

Expected behavior

The hook generator uses the type export provided by the installed Kit major. Kit 2 projects remain supported by the add-on's setup contract and generated hook imports type-check.

Actual behavior

TypeScript reports:

TS2459: Module '"@sveltejs/kit/hooks"' declares 'Handle' locally, but it is not exported.

Changing only the type import to @sveltejs/kit removes that diagnostic. The minimized type check exits 2 before the correction and 0 afterward.

Affected area

packages/sv-utils/src/tooling/js/kit.ts, specifically addHooksHandle, used by the Better Auth add-on. The helper also writes the hooks-module import in JSDoc annotations.

Runtime or environment

sv 1.0.1, SvelteKit 2.70.3, TypeScript 6.0.3, Better Auth 1.7.7, Svelte 5.57.1, Node.js 22.23.2, npm 12.0.2 on macOS ARM64.

Evidence

Current helper at revision 7ff52c0955e1f07b8719029d60afac1ee634ad69 always sources Handle from @sveltejs/kit/hooks. Kit 2.70.3 type declarations import Handle locally in that module but do not export it. An isolated check against those exact declarations confirms the failing and corrected imports.

Impact

Using a Kit 2 dependency graph to satisfy Better Auth's peer requirements still leaves an independently invalid generated hook. The regression condition is that the helper's output type-checks for each supported Kit major, including its TypeScript and JSDoc forms.

主要言語
TypeScript
スター
513
フォーク
110
平均マージ
5日 1時間
マージ済み PR(30日)
24

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

sveltejs/cli のほかの issue

sveltejs/cli の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。