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 CJS types #2880

Merged
merged 12 commits into from
Dec 12, 2023
Merged

Fix CJS types #2880

merged 12 commits into from
Dec 12, 2023

Conversation

thecrypticace
Copy link
Contributor

Fixes #2838

Comically enough our ESM types are correct for CJS as well because we don't use default nor do we need to use export = in CJS. We only have named exports for Headless UI.

This means that, in TypeScript, the export function, export let, etc… syntax all works fine for CJS.

Given that, there's a quick and dirty fix for this:

  • Copy the generated types file
  • Rename it to have a cts extension
  • Update exports to use point to these files separately

If we ever added a default export like export default then things would break but the Node 10 check would catch it. Likewise, if we ever did module.exports = … somewhere then the Node 16 check would catch that.

Copy link

vercel bot commented Dec 12, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
headlessui-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 12, 2023 4:40pm
headlessui-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 12, 2023 4:40pm

@thecrypticace thecrypticace changed the title Fix CTS types Fix CJS types Dec 12, 2023
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.

CommonJS Types appear incorrect
1 participant