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

Ensure types are declared first in exports field #996

Merged
merged 2 commits into from
Sep 18, 2023
Merged

Conversation

eps1lon
Copy link
Owner

@eps1lon eps1lon commented Sep 18, 2023

@changeset-bot
Copy link

changeset-bot bot commented Sep 18, 2023

🦋 Changeset detected

Latest commit: 5fcf56a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
dom-accessibility-api Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@hiebj
Copy link
Contributor

hiebj commented Sep 18, 2023

I heard this mentioned in a throwaway comment in a thread somewhere when I was researching this issue, but the comment provided no sources and I could not find a specific reference in TypeScript documentation that states it as a requirement or explains why it is necessary.

That being said the change should be harmless so if this is the way it's supposed to be you should do it!

@eps1lon
Copy link
Owner Author

eps1lon commented Sep 18, 2023

but the comment provided no sources and I could not find a specific reference in TypeScript documentation that states it as a requirement or explains why it is necessary.

It's a bit hidden under https://www.typescriptlang.org/docs/handbook/esm-node.html#packagejson-exports-imports-and-self-referencing:

The "types" condition should always come first in "exports".

It doesn't provide the "why" but I'm fine just taking their word for it.

@eps1lon eps1lon merged commit a6c21d5 into main Sep 18, 2023
6 checks passed
@eps1lon eps1lon deleted the eps1lon-patch-1 branch September 18, 2023 16:17
@github-actions github-actions bot mentioned this pull request Sep 18, 2023
@hiebj
Copy link
Contributor

hiebj commented Sep 18, 2023

The publint link explains it and provides a link to Typescript docs, that's very helpful, although the TS docs themselves only mention it in an aside with no rationale!

Publint says it is because it is order based so you want the types to resolve first. I don't get this exactly since it worked just fine (on my machine 😅) the other way. But I am also fine just taking their word for it, I did not test with many different versions of TypeScript.

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.

None yet

2 participants