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: resolution of types from ESM #58

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

Conversation

AlCalzone
Copy link

While migrating a project that depends on this package to ESM, I noticed that the type definitions are wrong. They try to make the package look like it contains ESM definitions, but this doesn't actually work, as can be tested with https://arethetypeswrong.github.io/

Removing the incorrect definitions lets TypeScript detect what this package really is: CommonJS and nothing more.

Output of arethetypeswrong before this change:

@serialport/bindings-interface v1.2.2

Build tools:
- [email protected]
- [email protected]
- [email protected]
- @microsoft/[email protected]

❌ Import resolved to JavaScript files, but no type declarations were found. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/UntypedResolution.md


┌───────────────────┬──────────────────────────────────┐
│                   │ "@serialport/bindings-interface" │
├───────────────────┼──────────────────────────────────┤
│ node10            │ 🟢                               │
├───────────────────┼──────────────────────────────────┤
│ node16 (from CJS) │ 🟢 (CJS)                         │
├───────────────────┼──────────────────────────────────┤
│ node16 (from ESM) │ ❌ No types                      │
├───────────────────┼──────────────────────────────────┤
│ bundler           │ ❌ No types                      │
└───────────────────┴──────────────────────────────────┘

Output of arethetypeswrong after this change:

@serialport/bindings-interface v0.0.0-development

Build tools:
- [email protected]
- [email protected]
- [email protected]
- @microsoft/[email protected]

 No problems found 🌟


┌───────────────────┬──────────────────────────────────┐
│                   │ "@serialport/bindings-interface" │
├───────────────────┼──────────────────────────────────┤
│ node10            │ 🟢                               │
├───────────────────┼──────────────────────────────────┤
│ node16 (from CJS) │ 🟢 (CJS)                         │
├───────────────────┼──────────────────────────────────┤
│ node16 (from ESM) │ 🟢 (CJS)                         │
├───────────────────┼──────────────────────────────────┤
│ bundler           │ 🟢                               │
└───────────────────┴──────────────────────────────────┘

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

Successfully merging this pull request may close these issues.

1 participant