Skip to content

fix: Add TypeScript 6 compatibility for config entry point#79

Open
bennycode wants to merge 1 commit intomrsteele:masterfrom
bennycode:fix/typescript6-config-exports
Open

fix: Add TypeScript 6 compatibility for config entry point#79
bennycode wants to merge 1 commit intomrsteele:masterfrom
bennycode:fix/typescript6-config-exports

Conversation

@bennycode
Copy link
Copy Markdown

@bennycode bennycode commented Apr 1, 2026

Summary

TypeScript 6 introduced error TS2882 which errors on side-effect imports that cannot resolve to type declarations. This breaks users who do:

import 'dotenv-defaults/config';
// or
import 'dotenv-defaults/config.js';

Two issues found:

  1. Missing ./config.js export — the exports map only has "./config", so import 'dotenv-defaults/config.js' (common in ESM/Node16 projects) doesn't resolve at all.
  2. No types condition — the export entries are bare strings with no types condition pointing to a .d.ts file, which TS6 now requires for side-effect imports.

Changes:

  • Add config.d.ts with an empty export {} side-effect type declaration
  • Add types conditions to all exports map entries
  • Add ./config.js export key alongside the existing ./config
  • Include config.d.ts in the files array so it ships with the package

TypeScript 6 introduced TS2882 which errors on side-effect imports
that cannot resolve to type declarations. This affected users doing
`import 'dotenv-defaults/config'` or `import 'dotenv-defaults/config.js'`.

Changes:
- Add `config.d.ts` with an empty `export {}` declaration
- Add `types` conditions to all export map entries
- Add `./config.js` export key (previously only `./config` existed)
- Include `config.d.ts` in the `files` array
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.

1 participant