Skip to content
New issue

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

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

Already on GitHub? # 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:
- typescript@4.5.5
- rollup@2.67.0
- esbuild@0.14.18
- @microsoft/api-extractor@7.19.4

❌ 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:
- typescript@5.1.6
- rollup@3.28.1
- esbuild@0.24.0
- @microsoft/api-extractor@7.36.4

 No problems found 🌟


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

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

Successfully merging this pull request may close these issues.

1 participant