arethetypeswrong / arethetypeswrong.github.io

Tool for analyzing TypeScript types of npm packages
https://arethetypeswrong.github.io
MIT License
1.18k stars 41 forks source link

What to do for missing export = when it's TypeScript's fault (kinda) #129

Closed benasher44 closed 9 months ago

benasher44 commented 9 months ago

ajv is an example of a package that uses TypeScript, but the generated .d.ts by TypeScript suffers from the missing export = issue (extra .default is needed when imported with NodeNext).

As a workaround, I'm opening a PR to their library to explicitly export the Ajv class, but I wasn't able to figure out the settings needed to get TypeScript to generate a better .d.ts. It would be great to update the docs to cover that case.

benasher44 commented 9 months ago

Actually I see you commented on that issue. I have some follow up questions. I'll follow up on that ticket.

andrewbranch commented 9 months ago

The source of the issue there, as far as declaration file correctness goes, is that the TS contains some direct module.exports manipulation, which the type system / TS module system doesn’t track.