Hello, I am using TS 5.2 and ESM modules ("module": "NodeNext" & "moduleResolution": "Node16"). I have also activated "esModuleInterop": true.
I am using RWS in the following way:
import ReconnectingWebSocket from 'reconnecting-websocket';
// ...
const socket = new ReconnectingWebSocket(this.baseURL, [], options);
However, I am getting this error:
This expression is not constructable.
Type 'typeof import("/home/bennycode/dev/bennycode/coinbase-pro-node/node_modules/reconnecting-websocket/dist/reconnecting-websocket")' has no construct signatures.ts(2351)
I can fix the error by writing:
socket = new ReconnectingWebSocket.default(this.baseURL, [], options);
But then my code crashes during execution with:
TypeError: ReconnectingWebSocket.default is not a constructor
How can I properly fix this error? I am currently cheating the compiler with:
const socket = new (ReconnectingWebSocket as any)(this.baseURL, [], options) as ReconnectingWebSocket.default;
Hello, I am using TS 5.2 and ESM modules (
"module": "NodeNext"
&"moduleResolution": "Node16"
). I have also activated"esModuleInterop": true
.I am using RWS in the following way:
However, I am getting this error:
I can fix the error by writing:
But then my code crashes during execution with:
How can I properly fix this error? I am currently cheating the compiler with: