Missing declaration file `redis` throw error when compiling with TypeScript with strict type checking
See original GitHub issueCould not find a declaration file for module 'redis'.
'/Users/totominc/Desktop/Git/battlr/node_modules/redis/index.js' implicitly has an 'any' type.
Try `npm install @types/redis` if it exists or add a new declaration (.d.ts) file containing `declare module 'redis';`
The only things I have done so far:
import * as Colyseus from 'colyseus';
export const server = new Colyseus.Server();
It can also be due to my tsconfig.json
which have the strict
property. This can be fixed by adding a vendor declaration file in Colyseus for redis (declare module 'redis';
).
It’s a bit annoying to manually add this dependency to fix an error which is from the framework.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Could not find a declaration file for module 'module-name ...
The compiler will let you know if you are using mismatched types, if you are out of your scope or you try to...
Read more >How to fix error TS7016: Could not find a declaration file for ...
How to fix error TS7016: Could not find a declaration file for module 'XYZ'. 'file.js' implicitly has an 'any' type · Try `npm...
Read more >A Complete Guide to Using TypeScript in Node.js - Better Stack
Executing TypeScript source files directly without compilation. Fixing errors caused by missing types. ... Step 3 — Type checking JavaScript files.
Read more >Adding Typescript to your Existing Rails App - Honeybadger.io
At this point, Webpack will take care of transpiling and type checking the files and will cause the build to fail if there...
Read more >How To Use Namespaces in TypeScript | DigitalOcean
Not every package available in the npm registry bundles its own TypeScript module declaration. This means that when installing a package in your ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think adding a dummy file would defeat the purpose of using types. Since redis is optional it should be up to the end user to install the corresponding types package.
That said, I think the solution is to add a note to the install section of the docs.
I’ve added
@types/redis
as adependency
on Colyseus. It’s ~100kb in the server just for typings but at least we don’t have unexpected errors on the consumer side anymore