You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to create a new WebSocketAsPromised using TypeScript, compiler throws an error if your WebSocket object is coming from some library such WebSocket-Node
Code:
import WebSocketAsPromised from 'websocket-as-promised'
import websocket from 'websocket'
const W3CWebSocket = websocket.w3cwebsocket
const ws = new WebSocketAsPromised('xxxx', {
createWebSocket: url => new W3CWebSocket(url)
})
Error:
Type '(url: string) => w3cwebsocket' is not assignable to type '(url: string) => WebSocket'.
Type 'w3cwebsocket' is missing the following properties from type 'WebSocket': addEventListener, removeEventListener, dispatchEvent
import WebSocketAsPromised from 'websocket-as-promised'
import websocket from 'websocket'
const W3CWebSocket = websocket.w3cwebsocket
const ws = new WebSocketAsPromised('xxxx', {
createWebSocket: url => new W3CWebSocket(url) as any
})
The text was updated successfully, but these errors were encountered:
When trying to create a new
WebSocketAsPromised
usingTypeScript
, compiler throws an error if your WebSocket object is coming from some library suchWebSocket-Node
Code:
Error:
Cause (type/options.d.ts):
Solution from client code
The text was updated successfully, but these errors were encountered: