Skip to content

Add 'types' field to 'exports' for modern TypeScript/Node resolution. #61

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DanielRosenwasser
Copy link

@DanielRosenwasser DanielRosenwasser commented May 9, 2025

TL;DR I ran the native port of TypeScript on Element. This PR helps make sure that Element can build cleanly with --moduleResolution bundler, and therefore, will build more cleanly with future versions of TypeScript.


If you run https://arethetypeswrong.github.io/ on this package, you'll get something like the following:

  "@vector-im/matrix-wysiwyg"
node10
node16 (from CJS) ❌ No types
node16 (from ESM) ❌ No types
bundler ❌ No types

While this package works:

  • at runtime for ESM consumers in modern versions of Node.js, and
  • at check time for TypeScript users who are using old resolution modes like --moduleResolution node (a.k.a. node10)

unfortunately, it will not correctly find the .d.ts file for projects that use modern Node.js resolution (e.g. --moduleResolution NodeNext or --moduleResolution Bundler). This matters because in upcoming versions of TypeScript, --module node10 will be deprecated. So projects like Element will have a build error.

This fix should fix the last two rows, though I believe things will still be off if consuming files from CJS (due to this issue). To fix that, you'll probably need slightly more involved change with a .d.cts file or something.

@CLAassistant
Copy link

CLAassistant commented May 9, 2025

CLA assistant check
All committers have signed the CLA.

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