Open JakobHock opened 2 weeks ago
Not sure if server.ws
is fixable since it assumes websocket server api. But, new ones like server.hot
and server.environments.client.hot
(on Vite 6) seems to work fine https://stackblitz.com/edit/stackblitz-starters-szagyj?file=vite.config.ts
Thank you very much. Then i will be using the server.hot for now.
It might be helpful to add something regarding the missing types to the docs, so that the user has to force it manually or use server.hot in vite 5 / environment api in v6. Should I open a PR for that?
Describe the bug
I'm building a custom devtools plugin that auto generates types for the user. For this i am using the custom websocket events.
The example works great for sending and receiving events on the client side. The type inference works for sending events on the server side but doesn't work for receiving events.
This seems to be caused be ws.on to be extending the
WebSocket.Server['on']
type of node. This has the type:and thus doesn't get inferred correctly.
This can be worked around by manually forcing the type of the call back function.
Reproduction
https://stackblitz.com/edit/stackblitz-starters-vipdit?file=vite.config.ts
Steps to reproduce
import.meta.hot
(client) andserver.ws.on
/server.ws.send
System Info
Used Package Manager
pnpm
Logs
No response
Validations