mem intellisense broken for JS
See original GitHub issueThis issue matches PR #30. I think it’s better to have a discussion here.
I believe this issue applies to all your packages that recently added types via d.ts files. I assume that the purpose was to improve intellisense. Right now, it works fine for Typescript users who have --esModuleInterop
turned on, but for normal JS use it’s broken:
const mem = require('./mem')
isn’t callable, even though the primary export of this package is a function.
Instead, people have to change their code to
const mem = require('./mem').default
which seems like it goes against the normal commonjs usage.
The d.ts file seems like it exists solely to provide better intellisense, and it consists solely of typescript syntax, so I think using the typescript syntax for commonjs exports make sense. That way people who use mem in editors with intellisense will not have to add .default
to all their existing require('./mem')
calls.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:34 (22 by maintainers)
There are 2 options:
If your default export is a class the whole definition becomes much more awkward:
As I said, if both consumer and producer are esm, it’d work fine, but if
mem
is still cjs (eg, because a consumer’s dependency is locked to this version), the default member of the default import is what’s going to be needed to work (according to the type definitions).Lemme be blunt with y’all: DO NOT WRITE DECLARATION FILES TODAY FOR TOMORROW’S NODE ESM IMPLEMENTATION.