Ioredis: Why are types in a separate package?

Created on 16 Jan 2020  路  4Comments  路  Source: luin/ioredis

I thought something must be wrong when I installed ioredis and then got the error:

Could not find a declaration file for module 'ioredis'. '/Users/dfee/myapp/node_modules/ioredis/built/index.js' implicitly has an 'any' type.
Try npm install @types/ioredis if it exists or add a new declaration (.d.ts) file containing declare module 'ioredis';ts(7016)

This is a project written in TypeScript, why aren't the types exported alongside the compiled JS?

wontfix

All 4 comments

Yeah, I also would like to know why -- I was really confused since I explicitely checked that the package is in TS, so I expected the type declarations to be bundled :)

Was this project only recently migrated to TS and doesn't ship bundled typings for now? It should be a matter of just enabling the declarations compiler flag. If no one has anything against doing it, I could try to do so and submit a PR (both here and a notice to definitely typed).

Thanks for the pull request! Declarations are not generated and published to npm is because there are many methods (like redis.get() / redis.mget()) are generated dynamically instead of being defined statically. So the automatically generated declarations will not contain those methods, which, I'm afraid, may mislead many developers.

Currently, they may keep using @types/ioredis before the above issue is solved.

from here: https://github.com/luin/ioredis/pull/981

If these generated type definitions are generated by the author/collaborators of this package, I still think they should be bundled with this package. Or at least it should be clearly mentioned in the README.

// Thanks for pulling out the explanation though!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 7 days if no further activity occurs, but feel free to re-open a closed issue if needed.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

No1Jie picture No1Jie  路  5Comments

jamesdixon picture jamesdixon  路  4Comments

pensierinmusica picture pensierinmusica  路  5Comments

kimmobrunfeldt picture kimmobrunfeldt  路  5Comments

haoxins picture haoxins  路  5Comments