Skip to content

Conversation

@BarryThePenguin
Copy link
Contributor

Introduces EmitterEnv to simplify Context types

@changeset-bot
Copy link

changeset-bot bot commented Dec 28, 2025

🦋 Changeset detected

Latest commit: e5b2966

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hono/event-emitter Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov
Copy link

codecov bot commented Dec 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.24%. Comparing base (5acf969) to head (e5b2966).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1669   +/-   ##
=======================================
  Coverage   92.24%   92.24%           
=======================================
  Files         111      111           
  Lines        3661     3661           
  Branches      967      956   -11     
=======================================
  Hits         3377     3377           
  Misses        250      250           
  Partials       34       34           
Flag Coverage Δ
arktype-validator 93.54% <ø> (ø)
auth-js 98.57% <ø> (ø)
bun-compress 18.91% <ø> (ø)
capnweb 60.71% <ø> (ø)
clerk-auth 88.46% <ø> (ø)
conform-validator 96.15% <ø> (ø)
esbuild-transpiler 100.00% <ø> (ø)
event-emitter 100.00% <100.00%> (ø)
graphql-server 92.15% <ø> (ø)
hello 100.00% <ø> (ø)
mcp 90.60% <ø> (ø)
node-ws 80.68% <ø> (ø)
oauth-providers 92.48% <ø> (ø)
otel 93.65% <ø> (ø)
prometheus 90.24% <ø> (ø)
sentry 77.27% <ø> (ø)
standard-validator 96.10% <ø> (ø)
swagger-ui 95.00% <ø> (ø)
trpc-server 69.56% <ø> (ø)
typedriver-validator 100.00% <ø> (ø)
ua-blocker 90.00% <ø> (ø)
valibot-validator 84.61% <ø> (ø)
zod-openapi 93.79% <ø> (ø)
zod-validator 91.30% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

* @returns The event handler.
*/
export const defineHandler = <
EPMap extends EventPayloadMap,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having the EPMap extends EventPayloadMap constraint makes it difficult to type Emitter and EmitterEnv correctly due to the circular reference

@yusukebe
Copy link
Member

@BarryThePenguin Thank you for the PR.

Hey @DavidHavl, can you review this?

@DavidHavl
Copy link
Contributor

@BarryThePenguin By introducing the EmitterEnv, you have indeed created a circular reference.
Removing the EventPayloadMap constraint (which dictates that key needs to be a string) isn’t a solution because it disables autocompletion in some cases and introduces potential errors (the key can be anything).
The constraint ensures type safety without creating coupling.

Copy link
Contributor

@DavidHavl DavidHavl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • By introducing the EmitterEnv, you have created a circular reference, so that is not desired.
  • Removing the EventPayloadMap constraint (which dictates that key needs to be a string) isn’t a solution because it disables autocompletion in some cases and introduces potential errors (the key can be anything). The constraint ensures type safety without creating coupling.

@BarryThePenguin BarryThePenguin marked this pull request as draft January 1, 2026 11:09
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.

3 participants