unjs / h3

⚡️ Minimal H(TTP) framework built for high performance and portability

Home Page:https://h3.unjs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Re-export websocket types

IlyaSemenov opened this issue · comments

Describe the feature

As a developer using websockets, I want to come up with generic helper functions working with websocket peers (such as for #715). However, h3 doesn't re-export the type of peer, so I have to use introspection types:

type Peer = Parameters<NonNullable<Parameters<typeof defineWebSocketHandler>[0]["open"]>>[0]

Not only this is cumbersome, but also it loses "genericness" of the original type.

I propose to re-export Peer directly from h3 (and some other involved types, e.g. Message, possibly others).

Additional information

  • Would you be willing to help implement this feature?

Just get them from crossws as in

import type { Peer, Message } from 'crossws'

Example repo + video