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

Problem with types #117

Open
Morb0 opened this issue Feb 14, 2021 · 8 comments
Open

Problem with types #117

Morb0 opened this issue Feb 14, 2021 · 8 comments

Comments

@Morb0
Copy link

Morb0 commented Feb 14, 2021

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
Copy link
Collaborator

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
Copy link
Author

Morb0 commented Feb 15, 2021

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
Copy link
Collaborator

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
Copy link
Author

Morb0 commented Feb 15, 2021

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
Copy link

Hey!
How to solve this problem?

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

34 export = LocalSession

@gabrieljaegerde
Copy link

Still having this issue too! not typescript compatible

@romap0
Copy link

romap0 commented Apr 8, 2022

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

@EdJoPaTo
Copy link
Collaborator

EdJoPaTo commented Apr 8, 2022

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.

@TemaSM TemaSM added this to the v3.x milestone Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants