Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

rijkvanzanten
Copy link
Contributor

h3 directly relies on crossws for it's WS handling, but doesn't make the crossws types available to consumers of h3. This in turn makes it quite hard to properly type functions that rely on the returned values in the WS handlers, as it forces the consumer of h3 to also add crossws as a devDependency and ensure that the version of crossws exactly matches the version in use by h3 to ensure there's no type conflicts. This is a pretty poor DX. By re-exporting the types used for the crossws logic that's relied on by h3 this problem is resolved.

I've identified Hooks, Peer, AdapterInternal, and Message as the ones you immediately run into when using defineWebSocketHandler, but there might be others. I didn't want to go as far as to export * as that'll add a bunch of unused types and other noise to h3s global scope as well.

Fixes #716

@rijkvanzanten rijkvanzanten requested a review from pi0 as a code owner September 6, 2025 19:00
@pi0 pi0 changed the title fix: re-export used crossws types types: export websocket related types Sep 8, 2025
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

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

Thanks!

@pi0 pi0 merged commit 443af8e into h3js:main Sep 29, 2025
3 checks passed
@codecov
Copy link

codecov bot commented Sep 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

Re-export websocket types

2 participants