Skip to content

[@types/ioredis-mock] Use export = for CJS module compatibility#74517

Open
rhnorskov wants to merge 1 commit intoDefinitelyTyped:masterfrom
rhnorskov:fix/ioredis-mock-cjs-export
Open

[@types/ioredis-mock] Use export = for CJS module compatibility#74517
rhnorskov wants to merge 1 commit intoDefinitelyTyped:masterfrom
rhnorskov:fix/ioredis-mock-cjs-export

Conversation

@rhnorskov
Copy link

Summary

ioredis-mock is a CJS package (no "type": "module") but @types/ioredis-mock uses ESM-style exports (export const redisMock; export { redisMock as default }). Under verbatimModuleSyntax: true + module: "nodenext" (the standard modern TS config from @tsconfig/node24 + @tsconfig/node-ts), the default import resolves to the module namespace type instead of Constructor, so new Redis() fails type checking.

The Fix

  • Switch from ESM-style named/default exports to export = with namespace declaration merging
  • This correctly models the CJS module shape (module.exports = redisMock)
  • Types (RedisOptions, ClusterConstructor, etc.) remain accessible via the namespace (e.g., IORedis.RedisOptions)
  • Remove ioredis-mock from attw.json failingPackages since the types now pass all resolution checks

Compatibility

  • esModuleInterop users: import Redis from "ioredis-mock" continues to work — TS synthesizes the default from export =
  • verbatimModuleSyntax / nodenext users: import Redis = require("ioredis-mock") now works correctly, and new Redis() resolves to Constructor
  • Named type imports: Change from import { RedisOptions } from "ioredis-mock" to import Redis = require("ioredis-mock"); type Opts = Redis.RedisOptions

Test plan

  • pnpm test ioredis-mock passes in DefinitelyTyped
  • attw shows all green (node10, node16 CJS/ESM, bundler)

ioredis-mock is a CJS package but @types/ioredis-mock used ESM-style
exports (export const + export { as default }). Under
verbatimModuleSyntax + module nodenext, the default import resolves to
the module namespace type instead of Constructor, breaking new Redis().

Switch to export = with namespace declaration merging so the types
correctly model the CJS module shape. This fixes usage under modern TS
configs (@tsconfig/node24 + @tsconfig/node-ts) while remaining
compatible with esModuleInterop users.
@typescript-bot
Copy link
Contributor

typescript-bot commented Feb 12, 2026

@rhnorskov Thank you for submitting this PR! I see this is your first time submitting to DefinitelyTyped 👋 — I'm the local bot who will help you through the process of getting things through.

This is a live comment that I will keep updated.

1 package in this PR

Code Reviews

Because you edited one package and updated the tests (👏), I can help you merge this PR once someone else signs off on it.

You can test the changes of this PR in the Playground.

Status

  • ✅ No merge conflicts
  • ✅ Continuous integration tests have passed
  • 🕐 Most recent commit is approved by type definition owners or DT maintainers

Once every item on this list is checked, I'll ask you for permission to merge and publish the changes.


Diagnostic Information: What the bot saw about this PR
{
  "type": "info",
  "now": "-",
  "pr_number": 74517,
  "author": "rhnorskov",
  "headCommitOid": "2186df63f9faa62d2eea0148b85a798988cedef0",
  "mergeBaseOid": "5a644d2e9afad5abbc916cc724fbdf995affdba8",
  "lastPushDate": "2026-02-12T21:46:29.000Z",
  "lastActivityDate": "2026-02-12T21:46:29.000Z",
  "maintainerBlessed": "Waiting for Code Reviews (Blessed)",
  "hasMergeConflict": false,
  "isFirstContribution": true,
  "tooManyFiles": false,
  "hugeChange": false,
  "popularityLevel": "Popular",
  "pkgInfo": [
    {
      "name": null,
      "kind": "edit",
      "files": [
        {
          "path": "attw.json",
          "kind": "infrastructure"
        }
      ],
      "owners": [],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Critical",
      "isSafeInfrastructureEdit": true
    },
    {
      "name": "ioredis-mock",
      "kind": "edit",
      "files": [
        {
          "path": "types/ioredis-mock/index.d.ts",
          "kind": "definition"
        },
        {
          "path": "types/ioredis-mock/ioredis-mock-tests.ts",
          "kind": "test"
        }
      ],
      "owners": [
        "lukaselmer"
      ],
      "addedOwners": [],
      "deletedOwners": [],
      "popularityLevel": "Popular"
    }
  ],
  "reviews": [],
  "mainBotCommentID": 3893569925,
  "ciResult": "pass"
}

@typescript-bot typescript-bot added the Popular package This PR affects a popular package (as counted by NPM download counts). label Feb 12, 2026
@typescript-bot typescript-bot moved this to Waiting for Code Reviews in Pull Request Status Board Feb 12, 2026
@typescript-bot
Copy link
Contributor

🔔 @lukaselmer — please review this PR in the next few days. Be sure to explicitly select Approve or Request Changes in the GitHub UI so I know what's going on.

@typescript-bot typescript-bot moved this from Waiting for Code Reviews to Needs Maintainer Review in Pull Request Status Board Feb 12, 2026
@RyanCavanaugh RyanCavanaugh moved this from Needs Maintainer Review to Waiting for Code Reviews (Blessed) in Pull Request Status Board Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Popular package This PR affects a popular package (as counted by NPM download counts).

Projects

Status: Waiting for Code Reviews (Blessed)

Development

Successfully merging this pull request may close these issues.

2 participants