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

types broken for typescript esm support #76

Closed
4 tasks done
philkunz opened this issue May 19, 2022 · 6 comments
Closed
4 tasks done

types broken for typescript esm support #76

philkunz opened this issue May 19, 2022 · 6 comments
Labels
💪 phase/solved Post is done

Comments

@philkunz
Copy link

Initial checklist

Affected packages and versions

5.3.2

Link to runnable example

No response

Steps to reproduce

The module identifies itself as type=module, yet the corresponding index.d.ts at https://unpkg.com/browse/vfile@5.3.2/lib/index.d.ts on lines 193, 194, 218 and 226 uses non esm compliant imports.
This causes the TypeScript compiler to fail when using new node12 and nodenext moduleResolution modes.

Expected behavior

should work

Actual behavior

does not work

Runtime

No response

Package manager

No response

OS

No response

Build and bundle tools

No response

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels May 19, 2022
@wooorm
Copy link
Member

wooorm commented May 19, 2022

What isn’t ESM about those imports?

Stuff works in all our ESM projects. Feel free to propose a solution that works for everyone

@philkunz
Copy link
Author

philkunz commented May 19, 2022

@wooorm import '..' maps to a directory. There are NO directory imports in esm. Esm ALWAYS requires a file specification with extension. The only exception is through either import maps or node modules (meaing when you import another node module, not a directory in a node module), where in both cases additional mappings (the import map or the package.json file) are needed to tell javascript what explicit file to import.

@wooorm
Copy link
Member

wooorm commented May 19, 2022

It works fine in TS in ESM, as the build here shows. If it doesn’t for you, perhaps you should report to TypeScript that they should generate .d.ts files that work with nodenext moduleResolution?

@philkunz
Copy link
Author

@wooorm Have you tried with the new nodenext resolution mode for TypeScript?
Also compare here: https://nodejs.org/api/esm.html
--> Mandatory file extensions

@philkunz
Copy link
Author

The problem is: You are using a non esm moduleResolution mode for TypeScript -> 'node', while it should be -> 'nodenext' for esm.

@wooorm
Copy link
Member

wooorm commented May 19, 2022

To reiterate, feel free to propose a solution that works for everyone.

@wooorm wooorm closed this as completed in 66189a4 Jun 9, 2022
@wooorm wooorm added the 💪 phase/solved Post is done label Jun 9, 2022
@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Jun 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 phase/solved Post is done
Development

No branches or pull requests

2 participants