Skip to content

types: export missing h3 types from runtime - #4378

Merged
pi0 merged 2 commits into
nitrojs:mainfrom
lachieh:main
Jun 24, 2026
Merged

types: export missing h3 types from runtime#4378
pi0 merged 2 commits into
nitrojs:mainfrom
lachieh:main

Conversation

@lachieh

@lachieh lachieh commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

🔗 Linked issue

Fixes #4344

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

When using a dependency manager that uses a symlink strategy such as pnpm, bun, or npm with the --install-strategy=linked flag, TypeScript will flag the types that come from these module paths as non-portable, which is correct.

export default defineHandler((request) => {
  // ...
});

// Error: The inferred type of 'default' cannot be named without a reference to 'EventHandlerRequest' from '.bun/h3@2.0.1-rc.22+a8f2d2f34545c24c/node_modules/h3'. This is likely not portable. A type annotation is necessary.ts(2883)

This PR exports the types that are depended upon by the exported h3 helpers.

The alternative is making h3 a peerDependency or documenting that users install "h3" as a direct dependent of their project, but that feels like a lot more hoop-jumping when h3 is so integral to nitro.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@lachieh
lachieh requested a review from pi0 as a code owner June 23, 2026 17:09
@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

@lachieh is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

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: cc4d4316-e7df-4059-bb44-554cafce4098

📥 Commits

Reviewing files that changed from the base of the PR and between 2fe3295 and 7264bd1.

📒 Files selected for processing (1)
  • src/runtime/nitro.ts
✅ Files skipped from review due to trivial changes (1)
  • src/runtime/nitro.ts

📝 Walkthrough

Walkthrough

src/runtime/nitro.ts expands its h3 type re-export to include EventHandlerRequest and EventHandlerWithFetch in addition to H3Event. No runtime logic changes.

Changes

h3 type re-export expansion

Layer / File(s) Summary
Add EventHandlerRequest and EventHandlerWithFetch to h3 re-exports
src/runtime/nitro.ts
The export type statement for h3 now includes EventHandlerRequest and EventHandlerWithFetch alongside H3Event.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related issues

  • #4344 – TypeScript throws an error due to defineHandler attempting to use unexported types: this change exports EventHandlerRequest, addressing the reported naming error when using defineHandler without a direct h3 import.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title uses a conventional commit-style prefix and clearly describes exporting missing h3 types.
Description check ✅ Passed The description is directly about fixing the TypeScript portability issue caused by missing h3 type exports.
Linked Issues check ✅ Passed The change exports the h3 types needed by defineHandler, matching issue #4344's portability error.
Out of Scope Changes check ✅ Passed The PR is narrowly scoped to the runtime type re-export needed for the reported TypeScript issue.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

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

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.

@pi0 pi0 changed the title fix(runtime): export required types from 'h3' types: export missing h3 types from runtime Jun 24, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nitro@4378

commit: 7264bd1

@pi0
pi0 merged commit 37db9ee into nitrojs:main Jun 24, 2026
11 of 12 checks passed
pi0x pushed a commit to ulrichstark/nitro that referenced this pull request Jun 30, 2026
@pi0 pi0 mentioned this pull request Aug 21, 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.

TypeScript throws an error due to defineHandler attempting to use unexported types

2 participants