[@types/ioredis-mock] Use export = for CJS module compatibility#74517
Open
rhnorskov wants to merge 1 commit intoDefinitelyTyped:masterfrom
Open
[@types/ioredis-mock] Use export = for CJS module compatibility#74517rhnorskov wants to merge 1 commit intoDefinitelyTyped:masterfrom
rhnorskov wants to merge 1 commit intoDefinitelyTyped:masterfrom
Conversation
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.
Contributor
|
@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 PRCode ReviewsBecause 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
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"
} |
Contributor
|
🔔 @lukaselmer — please review this PR in the next few days. Be sure to explicitly select |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ioredis-mockis a CJS package (no"type": "module") but@types/ioredis-mockuses ESM-style exports (export const redisMock; export { redisMock as default }). UnderverbatimModuleSyntax: true+module: "nodenext"(the standard modern TS config from@tsconfig/node24+@tsconfig/node-ts), the default import resolves to the module namespace type instead ofConstructor, sonew Redis()fails type checking.The Fix
export =with namespace declaration mergingmodule.exports = redisMock)RedisOptions,ClusterConstructor, etc.) remain accessible via the namespace (e.g.,IORedis.RedisOptions)ioredis-mockfromattw.jsonfailingPackagessince the types now pass all resolution checksCompatibility
esModuleInteropusers:import Redis from "ioredis-mock"continues to work — TS synthesizes the default fromexport =verbatimModuleSyntax/nodenextusers:import Redis = require("ioredis-mock")now works correctly, andnew Redis()resolves toConstructorimport { RedisOptions } from "ioredis-mock"toimport Redis = require("ioredis-mock"); type Opts = Redis.RedisOptionsTest plan
pnpm test ioredis-mockpasses in DefinitelyTypedattwshows all green (node10, node16 CJS/ESM, bundler)