RealSpeaker / telegraf-session-local

Telegraf local sessions middleware with multiple supported storage types (Memory/FileSync/FileAsync/...) using lowdb
https://git.io/v7iw9
MIT License
93 stars 10 forks source link

Problem with types #117

Open Morb0 opened 3 years ago

Morb0 commented 3 years ago

Hey, just install package and got types error:


node_modules/telegraf-session-local/lib/session.d.ts:34:3 - error TS2309: An export assignment cannot be used in a module with other exported elements.

34   export = LocalSession
     ~~~~~~~~~~~~~~~~~~~~~

Seems it because also interface exported. I think change export = LocalSession to export default LocalSession can fix this. Now I can't really use this package.

EdJoPaTo commented 3 years ago

I use this as it is in multiple bots. Check for example my template which also works.

Typings are not ideal but they work good enough for me. The only thing that would really improve types in my opinion would be a (breaking) refactoring into native typescript. Then types are exactly the same as the underlying JavaScript.

Morb0 commented 3 years ago

I tried the import like you, but still the same problem I use the latest version which is 2.1.0 and my telegraf version is 4.0.3.

EdJoPaTo commented 3 years ago

If you have esModuleInterop enabled (in tsconfig.json) you might need an import without * as. Personally I try to avoid esModuleInterop as it also works without (as long as the modules I use dont have it).

Morb0 commented 3 years ago

Yes, I do the same. I have already tried with both enabled and disabled esModuleInterop, but this is an error in the export types, WebStorm highlight this.

TEHbKA-dev commented 3 years ago

Hey! How to solve this problem?

An export assignment cannot be used in a module with other exported elements.

34 export = LocalSession

gabrieljaegerde commented 3 years ago

Still having this issue too! not typescript compatible

romap0 commented 2 years ago

Using "skipLibCheck": true in tsconfig.json fixed this for me

EdJoPaTo commented 2 years ago

As people check this issue I will suggest it here again: I strongly suggest using grammY over Telegraf as it has a lot of benefits while being mostly API compatible. Its documentation is way better and was built with the learnings from Telegraf which allows for better performance, simpler and more powerful code syntax.

If you care for TypeScript (which is probably true as you seek this issue) then grammY will be way more helpful and correct than Telegraf can as grammY was built with types in mind.