Nerixyz / instagram_mqtt

Realtime and Push Notification (FBNS) support for the instagram-private-api
MIT License
244 stars 49 forks source link

typeof EventEmitter error when building with TypeScript #52

Closed ypk46 closed 3 years ago

ypk46 commented 3 years ago

I am getting this error whenever I try to build my code using TypeScript:

node_modules/instagram_mqtt/dist/fbns/fbns.client.d.ts:7:41 - error TS2507: Type 'typeof EventEmitter' is not a constructor function type.

This may be related to this and I think it only happens if you are using (or a package have a dependency of) @types/node > 13.

Nerixyz commented 3 years ago

I can't reproduce this bug. Could you share a repl/example? Also, the comment you linked refers to Node's EventEmitter. This library doesn't use this EventEmitter.

ypk46 commented 3 years ago

@Nerixyz Thank you for your fast response, I now see that the library (alpha version) use eventemitter3 not Node's EventEmitter.

Anyways, I was able to identify the cause of the issue being having the esModuleInterop enable. You can reproduce it, by enabling esModuleInterop while having skipLibCheck disable in your ts-config.json.

Changing the import syntax of eventemitter3 to import EventEmitter from 'eventemitter3'; may solve this issue. But if anyone run into this, you can also enable skipLibCheck as a workaround.