Skip to content

@types/ws is missing which results in loosing typing withing handler #300

Open
@cyantree

Description

@cyantree

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

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 from ws which isn't listed as a dependency.

app.get('/new-status-route', {websocket: true}, async (socket, req) => {
// socket is any instead of WebSocket.WebSocket

Therefore it's necessary to install it additionally.

I think the typical solution would be listing it in dependencies rathern than devDependencies.

Link to code that reproduces the bug

No response

Expected Behavior

The plugin also installs @types/ws which leads to the correct type of socket within the handler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions