telegraf-session-local icon indicating copy to clipboard operation
telegraf-session-local copied to clipboard

Problem with types

Open Morb0 opened this issue 4 years ago • 8 comments

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.

Morb0 avatar Feb 14 '21 20:02 Morb0

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.

EdJoPaTo avatar Feb 14 '21 22:02 EdJoPaTo

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.

Morb0 avatar Feb 15 '21 01:02 Morb0

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).

EdJoPaTo avatar Feb 15 '21 09:02 EdJoPaTo

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.

Morb0 avatar Feb 15 '21 10:02 Morb0

Hey! How to solve this problem?

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

34 export = LocalSession

TEHbKA-dev avatar Sep 09 '21 06:09 TEHbKA-dev

Still having this issue too! not typescript compatible

gabrieljaegerde avatar Sep 16 '21 19:09 gabrieljaegerde

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

romap0 avatar Apr 08 '22 00:04 romap0

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.

EdJoPaTo avatar Apr 08 '22 08:04 EdJoPaTo