Skip to content

fix: use separate .d.ts types for import vs .d.cts for require - #6275

Open
deepshekhardas wants to merge 1 commit into
colinhacks:mainfrom
deepshekhardas:fix/cjs-types-for-import
Open

fix: use separate .d.ts types for import vs .d.cts for require#6275
deepshekhardas wants to merge 1 commit into
colinhacks:mainfrom
deepshekhardas:fix/cjs-types-for-import

Conversation

@deepshekhardas

Copy link
Copy Markdown

Fixes #5686.

Problem

The exports field in package.json uses types: "./index.d.cts" for both import and require conditions. When TypeScript's module resolution is set to nodenext, the .d.cts extension signals CJS module format, causing TypeScript to apply CJS interop rules — producing z.z.* paths in emitted declarations and breaking type inference in ESM projects.

Fix

Split the types condition per import/require:

  • importtypes: "./index.d.ts"
  • requiretypes: "./index.d.cts"

Applied to all export subpaths (mini, locales, v3, v4, etc.).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zod incorrectly points to CommonJS declaration when used with ESM

1 participant