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

This expression is not constructable #196

Open
bennycode opened this issue Oct 26, 2023 · 1 comment
Open

This expression is not constructable #196

bennycode opened this issue Oct 26, 2023 · 1 comment

Comments

@bennycode
Copy link
Contributor

bennycode commented Oct 26, 2023

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;
@knJayden
Copy link

I am still having this issue

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

2 participants