fastify / fastify-websocket

basic websocket support for fastify
MIT License
394 stars 72 forks source link

Fix Websocket Types: TS1259 because "ws" package using "export =" #283

Closed bstka closed 8 months ago

bstka commented 9 months ago

Prerequisites

Fastify version

4.21.0

Plugin version

8.5.10

Node.js version

18.17.1

Operating system

Linux

Operating system version (i.e. 20.04, 11.3, 10)

Pop_os! 22.04

Description

Before fixing this bug, fastify.websocketServer it doesnt have any resolved auto completion/types in vscode, when I open the type definition it throw error TS1259, because ws package use export = Websocket.

I fix this issue when I change import WebSocket from "ws" to import * as WebSocket from "ws" directly in node_modules/@types/fastify-websocket or in this repo type definition

Steps to Reproduce

hovering fastify.websocketServer and open node_modules/@types/fastify-websocket/index.d.ts

Expected Behavior

Expected resolved type definition and autocomplete in vscode