From 10c93e42044740aecf665077f241e28861f5bade Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Tue, 12 May 2026 21:11:30 -0700 Subject: [PATCH] Add type declarations with export conditions --- CLAUDE.md | 10 ++++++++++ package.json | 11 +++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index b8100b7..bcc0181 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -109,3 +109,13 @@ bun --hot ./index.ts ``` For more information, read the Bun API docs in `node_modules/bun-types/docs/**.md`. + +## Type Declarations + +This package exports raw `.tsx` source as the runtime entry (Bun handles it fine), but uses hand-written `.d.ts` files in `dist/` for the `types` export condition. This prevents consumers' `tsc` from type-checking our Hono JSX internals, which would fail if they use a different JSX runtime. + +- When adding or changing exported functions/types, update the corresponding `.d.ts` file in `dist/` by hand. +- Do NOT add a build step to generate declarations. The `.d.ts` files are small and manually maintained. +- `dist/index.d.ts` — main exports (`Hype` class, `HypeProps`, `SSEHandler`, re-exports from utils/layout) +- `dist/utils.d.ts` — utility function signatures +- `dist/layout.d.ts` — `Layout` and `ReloadScript` FC declarations diff --git a/package.json b/package.json index 02eec1b..ed930d6 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,17 @@ "module": "src/index.tsx", "type": "module", "exports": { - ".": "./src/index.tsx", - "./utils": "./src/utils.tsx" + ".": { + "types": "./dist/index.d.ts", + "default": "./src/index.tsx" + }, + "./utils": { + "types": "./dist/utils.d.ts", + "default": "./src/utils.tsx" + } }, "files": [ + "dist", "src/css", "src/frontend.ts", "src/index.tsx",