question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing declaration file `redis` throw error when compiling with TypeScript with strict type checking

See original GitHub issue
Could 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
seiyriacommented, Jun 12, 2018

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.

0reactions
endelcommented, Apr 7, 2019

I’ve added @types/redis as a dependency 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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found