You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
on(event: string|symbol,listener: (this: Server<T>, ...args: any[])=>void): this
and thus doesn't get inferred correctly.
This can be worked around by manually forcing the type of the call back function.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
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
The text was updated successfully, but these errors were encountered: