[X] I have searched existing issues to ensure the bug has not already been reported
Fastify version
4.17.0
Plugin version
8.0.0
Node.js version
16.20.0
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Pop!_OS 22.04
Description
The problem is in the d.ts file. The WebSocket is imported as import * as WebSocket from 'ws', but ws has 2 different d.ts files: the regular one and .mts one, the regular one has a single export export = WebSocket, but the .mts one exports functions, types and the WebSocket itself, resulting in type WebSocket = /*unresolved*/ any.
I haven't seen this problem using "moduleResolution": "node".
Just by changing import * as WebSocket from 'ws' to import WebSocket from 'ws' the problem resolves. If that's okay i can PR fixes.
Prerequisites
Fastify version
4.17.0
Plugin version
8.0.0
Node.js version
16.20.0
Operating system
Linux
Operating system version (i.e. 20.04, 11.3, 10)
Pop!_OS 22.04
Description
The problem is in the d.ts file. The
WebSocket
is imported asimport * as WebSocket from 'ws'
, butws
has 2 different d.ts files: the regular one and .mts one, the regular one has a single exportexport = WebSocket
, but the .mts one exports functions, types and theWebSocket
itself, resulting intype WebSocket = /*unresolved*/ any
. I haven't seen this problem using"moduleResolution": "node"
.Just by changing
import * as WebSocket from 'ws'
toimport WebSocket from 'ws'
the problem resolves. If that's okay i can PR fixes.Steps to Reproduce
pnpm install
index.ts
moduleResolution
tonode
intsconfig.json
index.ts
moduleResolution
tobundler
intsconfig.json
import * as WebSocket from 'ws'
toimport WebSocket from 'ws'
in the d.ts fileindex.ts
Expected Behavior
The
WebSocket
type doesn't resolve to/*unresolved*/ any
using ESM andmoduleResolution: "bundler"
.