-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@types/ws
is missing which results in loosing typing withing handler
#300
Comments
This is as at odds with devs wanting less modules in production, and there is no way to achieve boths. |
I think this covers the scenario well:
I totally agree that having to install fewer modules in production is a good thing, however besides the additional module that needs to be installed the amount of code is quite similar in comparison with a package that already has type definitions included. |
I'm not sure if this is related but I cannot get any TypeScript autocompletes for (No autocomplete is shown when I type However, if I do this it works Meanwhile the type completions for other |
I worked around my own issue with module augmentation and a new decorator... declare module "fastify" {
export interface FastifyInstance {
get wss(): import("ws").WebSocketServer;
}
}
fastifyInstance.decorate("wss", {
getter() {
return this.websocketServer;
},
}); Now I get type completions for |
Prerequisites
Fastify version
4.27.0
Plugin version
10.0.1
Node.js version
20.12.2
Operating system
Windows
Operating system version (i.e. 20.04, 11.3, 10)
10
Description
When using this plugin with TypeScript the socket within the handler isn't typed correctly because it reexports
WebSocket.WebSocket
fromws
which isn't listed as a dependency.Therefore it's necessary to install it additionally.
I think the typical solution would be listing it in
dependencies
rathern thandevDependencies
.Link to code that reproduces the bug
No response
Expected Behavior
The plugin also installs
@types/ws
which leads to the correct type ofsocket
within the handler.The text was updated successfully, but these errors were encountered: