Skip to content

Add .d.mts file#85

Merged
guybedford merged 1 commit intonodejs:mainfrom
Andarist:fix/dmts-types
May 15, 2023
Merged

Add .d.mts file#85
guybedford merged 1 commit intonodejs:mainfrom
Andarist:fix/dmts-types

Conversation

@Andarist
Copy link
Copy Markdown
Contributor

I moved types condition to the front. package.json#exports are order-sensitive - they are always matched from the top to the bottom. When a match is found then it should be used and no further matching should occur.

Right now, the current setup works in TypeScript but it's considered a bug and it should not be relied upon, see the thread and the comment here. For that reason, I would like to fix all popular packages that misconfigured their exports this way so the bug can be fixed in TypeScript.

⚠️ See the reported problems here. This PR only focuses on "🐛 Used fallback condition" because that's a TypeScript bug that can't be fixed before the usage gets fixed in popular packages. However, I think that the second problem (🎭 Masquerading as CJS) should also get fixed by this. Reexporting types like this isn't technically 100% correct (your implementation is duplicated between CJS and ESM and so the types should be too) but I think it's fairly OK to do it this way here since you don't export any nominal types or anything like that.

@Andarist
Copy link
Copy Markdown
Contributor Author

Andarist commented May 9, 2023

cc @guybedford

@guybedford
Copy link
Copy Markdown
Collaborator

Looks ok to me. Thanks @Andarist.

@guybedford guybedford merged commit 2100e2c into nodejs:main May 15, 2023
@Andarist
Copy link
Copy Markdown
Contributor Author

Andarist commented Jun 1, 2023

@guybedford would you be able to cut a new release with this small change?

@guybedford
Copy link
Copy Markdown
Collaborator

@Andarist sure, I've published a 1.2.3, let me know if that is working ok for you.

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.

2 participants