fix: Add TypeScript 6 compatibility for config entry point#79
Open
bennycode wants to merge 1 commit intomrsteele:masterfrom
Open
fix: Add TypeScript 6 compatibility for config entry point#79bennycode wants to merge 1 commit intomrsteele:masterfrom
bennycode wants to merge 1 commit intomrsteele:masterfrom
Conversation
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
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
TypeScript 6 introduced error TS2882 which errors on side-effect imports that cannot resolve to type declarations. This breaks users who do:
Two issues found:
./config.jsexport — theexportsmap only has"./config", soimport 'dotenv-defaults/config.js'(common in ESM/Node16 projects) doesn't resolve at all.typescondition — the export entries are bare strings with notypescondition pointing to a.d.tsfile, which TS6 now requires for side-effect imports.Changes:
config.d.tswith an emptyexport {}side-effect type declarationtypesconditions to allexportsmap entries./config.jsexport key alongside the existing./configconfig.d.tsin thefilesarray so it ships with the package