fix(types): export ThrowHttpError from public entry to fix TS2742/TS2883 in composite projects#261
fix(types): export ThrowHttpError from public entry to fix TS2742/TS2883 in composite projects#261gkurt wants to merge 1 commit into
ThrowHttpError from public entry to fix TS2742/TS2883 in composite projects#261Conversation
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe PR exposes the ChangesThrowHttpError public export
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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
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. Comment |
Why
treaty(app, config)returns a type that expands throughTreaty.Config, whosethrowHttpErrorfield referencesThrowHttpError. That type lives only in the internal, content-hash-named declaration bundle (dist/types-<hash>.d.ts), and the packageexportsmap exposes no public path to it.So any consumer that emits declarations —
composite: true,declaration: true, orisolatedDeclarations— cannot nameThrowHttpErrorportably and fails the moment it re-exports atreaty(...)value:EdenFetchError(a sibling type in the same internal bundle) is already re-exported from the public entry and causes no such error.ThrowHttpErrorwas simply missing the same treatment — this PR gives it that, exactly the wayEdenFetchErroris handled. Type-only; no runtime behavior changes.Verification
composite: true,moduleResolution: nodenext,export const api = treaty(app)) built against the packed package: fails before with thenot portableerror pointing atdist/types-<hash>.js, passes after — the emitted.d.tsnow names it asimport("@elysia/eden").ThrowHttpError.dist/index.d.tsre-exportsThrowHttpErroralongsideEdenFetchError.import type { ThrowHttpError } from '@elysia/eden'resolves.ThrowHttpErrorfrom the public entry, so it guards this re-export;bun test:typespasses.Summary by CodeRabbit
ThrowHttpErrortype is now exported from the main package entry point, making it more convenient to import and use.