Skip to content

TS7016: Could not find a declaration file for module 'redis-errors' (since 6.1.0) #2319

Done

Description

@benevolent0505

Since 6.1.0, tsc reports errors in the ioredis type declarations when the project has strict (or noImplicitAny) enabled and skipLibCheck disabled. 6.0.0 works.

Versions: ioredis 6.1.0, TypeScript 5.9.3, Node.js 24.15.0, Redis not applicable (compile-time error)

Reproduction

package.json

{
  "type": "module",
  "dependencies": {
    "ioredis": "6.1.0"
  },
  "devDependencies": {
    "@types/node": "^20",
    "typescript": "^5"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "module": "nodenext",
    "strict": true,
    "noEmit": true
  }
}

index.ts

import { Redis } from "ioredis";

Run npm install && npx tsc:

node_modules/ioredis/built/errors/MaxRetriesPerRequestError.d.ts(1,28): error TS7016: Could not find a declaration file for module 'redis-errors'. '.../node_modules/redis-errors/index.js' implicitly has an 'any' type.
node_modules/ioredis/built/errors/WatchError.d.ts(1,28): error TS7016: Could not find a declaration file for module 'redis-errors'. '.../node_modules/redis-errors/index.js' implicitly has an 'any' type.

Expected: tsc passes without installing @types/redis-errors in the project, as with 6.0.0.

Cause

#2165 re-exported WatchError and MaxRetriesPerRequestError from the package entry point. Their declaration files import redis-errors, which does not include type declarations, and @types/redis-errors is only in the devDependencies of ioredis.

As a workaround, you can install @types/redis-errors in your project, or set skipLibCheck: true.

Proposed fix

I'd suggest moving @types/redis-errors from devDependencies to dependencies.

Activity

  1. rome-xi commented on Dec 1, 2026

    @rome-xi

    I can reproduce this on 466f6be; working on a fix with a test.

  2. PavelPashov commented on Dec 1, 2026

    @PavelPashov
    Contributor

    @benevolent0505 Thank you for reporting this, I've reproduce it and will look into it

  3. self-assigned this
    on Dec 1, 2026
  4. PavelPashov commented on Dec 1, 2026

    @PavelPashov
    Contributor

    @benevolent0505 #2322 fixes this by keeping redis-errors out of the published declarations of WatchError and MaxRetriesPerRequestError, so your project won't need @types/redis-errors. We considered moving @types/redis-errors into dependencies, but that would install an @types package for every user, including plain-JS ones, which felt like poor package hygiene. Ideally we'd drop redis-errors entirely, but replacing its classes changes instanceof behavior, so that has to wait for a major release.

    With your exact package.json and tsconfig.json, tsc reports both TS7016 errors on 6.1.0 and passes on a tarball built from the branch. instanceof AbortError still returns true for both errors.

    Would you mind reviewing the PR and letting us know whether this approach works for your setup?

  5. benevolent0505 commented on Dec 1, 2026

    @benevolent0505
    Author

    @PavelPashov I confirmed that this approach resolves the TS7016 errors in my setup. I agree with not moving @types/redis-errors into dependencies.
    Thanks for the quick fix!

  6. github-actions commented on Dec 2, 2026

    @github-actions

    🎉 This issue has been resolved in version 6.1.1 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions