Skip to content
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

TS2304: Cannot find name 'WebSocket'. #1746

Closed
JimmyBjorklund opened this issue Nov 27, 2023 · 4 comments
Closed

TS2304: Cannot find name 'WebSocket'. #1746

JimmyBjorklund opened this issue Nov 27, 2023 · 4 comments

Comments

@JimmyBjorklund
Copy link
Contributor

JimmyBjorklund commented Nov 27, 2023

node_modules/mqtt/build/lib/shared.d.ts:10:14 - error TS2304: Cannot find name 'WebSocket'.

This line seams to be missing
import type { WebSocket } from 'ws';

This issue was introduced in 5.3.0, its not present in 5.2.2

@robertsLando
Copy link
Member

robertsLando commented Nov 27, 2023

@JimmyBjorklund That's strange as I should get the same error on compilation too. That websocket is not the ws Websocket, it's https://developer.mozilla.org/en-US/docs/Web/API/WebSocket and them are really different.

Maybe some types are missing ?

try add: "skipLibCheck": true to your tsconfig

@Koenkk
Copy link

Koenkk commented Nov 27, 2023

Having exactly the same issue (link).

"skipLibCheck": true suppresses the issue but not acceptable because it reduce the type-system accuracy

@robertsLando
Copy link
Member

@Koenkk Do you guys have a suggestion about how I could explicitly make it to return window.Websocket type instead ws Websocket?

@robertsLando
Copy link
Member

5.3.1 is coming, sorry for the inconvenience...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants