Skip to content

fix(types): export ThrowHttpError from public entry to fix TS2742/TS2883 in composite projects#261

Open
gkurt wants to merge 1 commit into
elysiajs:mainfrom
gkurt:fix/export-throw-http-error
Open

fix(types): export ThrowHttpError from public entry to fix TS2742/TS2883 in composite projects#261
gkurt wants to merge 1 commit into
elysiajs:mainfrom
gkurt:fix/export-throw-http-error

Conversation

@gkurt

@gkurt gkurt commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Why

treaty(app, config) returns a type that expands through Treaty.Config, whose throwHttpError field references ThrowHttpError. That type lives only in the internal, content-hash-named declaration bundle (dist/types-<hash>.d.ts), and the package exports map exposes no public path to it.

So any consumer that emits declarations — composite: true, declaration: true, or isolatedDeclarations — cannot name ThrowHttpError portably and fails the moment it re-exports a treaty(...) value:

The inferred type of 'api' cannot be named without a reference to
'.../node_modules/@elysia/eden/dist/types-<hash>.js'. This is likely not
portable. A type annotation is necessary.   // TS2742 / TS2883

EdenFetchError (a sibling type in the same internal bundle) is already re-exported from the public entry and causes no such error. ThrowHttpError was simply missing the same treatment — this PR gives it that, exactly the way EdenFetchError is handled. Type-only; no runtime behavior changes.

Verification

  • Repro (composite: true, moduleResolution: nodenext, export const api = treaty(app)) built against the packed package: fails before with the not portable error pointing at dist/types-<hash>.js, passes after — the emitted .d.ts now names it as import("@elysia/eden").ThrowHttpError.
  • dist/index.d.ts re-exports ThrowHttpError alongside EdenFetchError.
  • import type { ThrowHttpError } from '@elysia/eden' resolves.
  • The existing type test now imports ThrowHttpError from the public entry, so it guards this re-export; bun test:types passes.

CHANGELOG entries are added at release time by the maintainer, so I left it for the release commit.

Summary by CodeRabbit

  • API Changes
    • The ThrowHttpError type is now exported from the main package entry point, making it more convenient to import and use.

treaty(app, config) returns a type that expands through Treaty.Config,
whose throwHttpError field references ThrowHttpError. The type was only
reachable via the internal hash-named declaration bundle, which is not in
the package exports map. Consumers compiling with composite/declaration/
isolatedDeclarations therefore hit TS2742/TS2883 ("inferred type cannot be
named ... not portable") when re-exporting a treaty(...) value.

Re-export ThrowHttpError from the public entry, the same way EdenFetchError
already is, so the emitted declaration can name it via @elysia/eden.

Type-only change; no runtime behavior is affected.
@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7b093398-832b-474a-b079-6c1c46d32cc8

📥 Commits

Reviewing files that changed from the base of the PR and between 54eaa41 and 6d166a6.

📒 Files selected for processing (2)
  • src/index.ts
  • test/types/treaty2.ts

Walkthrough

The PR exposes the ThrowHttpError type from the package's main entrypoint by re-exporting it in src/index.ts, then updates a type test to import from the new public location instead of directly from the types module.

Changes

ThrowHttpError public export

Layer / File(s) Summary
Export ThrowHttpError from package entrypoint
src/index.ts, test/types/treaty2.ts
ThrowHttpError is re-exported from src/index.ts for public API access, and the type test is updated to import from the package root instead of the internal types module.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Suggested reviewers

  • SaltyAom

✨ Exposing your precious types~? (๑•́ ω •̀)و
How thoughtful of youuu... now everyone can reach your ThrowHttpError
Just two lines, yet the whole world changes~ ehehe ♡

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: exporting ThrowHttpError from the public entry point to fix TypeScript composite project issues (TS2742/TS2883).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant