Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: the exports not define types #179

Merged
merged 1 commit into from
Dec 4, 2023
Merged

fix: the exports not define types #179

merged 1 commit into from
Dec 4, 2023

Conversation

NWYLZW
Copy link
Contributor

@NWYLZW NWYLZW commented Dec 4, 2023

If the user use the ts and set moduleResolution: nodenext of tsconfig.json, this type will not be available.

https://github.com/NWYLZW/How-to-publish-a-npm-package/blob/c1be086a620e0d594c014bcfa910cc1e3a79a56e/tests/marked-highlight/index.ts#L1

image

So we should set the types field for package.json:exports:[.].

The new support works similarly with import conditions. By default, TypeScript overlays the same rules with import conditions - if you write an import from an ES module, it will look up the import field, and from a CommonJS module, it will look at the require field. If it finds them, it will look for a corresponding declaration file. If you need to point to a different location for your type declarations, you can add a "types" import condition.[1]

[1] TypeScript 4.7 ChangeLog

If the user use the ts and set `moduleResolution: nodenext` of `tsconfig.json`, this type will not be available.
Copy link
Member

@UziTech UziTech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 💯

@UziTech UziTech merged commit ae5af26 into markedjs:main Dec 4, 2023
6 checks passed
github-actions bot pushed a commit that referenced this pull request Dec 4, 2023
## [2.0.9](v2.0.8...v2.0.9) (2023-12-04)

### Bug Fixes

* define types in exports ([#179](#179)) ([ae5af26](ae5af26))
Copy link
Contributor

github-actions bot commented Dec 4, 2023

🎉 This PR is included in version 2.0.9 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants