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
Typings resolution error with TS 4.7 in "Node16" mode #1629
Comments
Yes! PR welcome :) |
Repro sample (used in the following PR): telegraf1629repro.zip |
2 tasks
Telegraf is currently the only library keeping me from fully converting to ESM. I really appreciate the effort! 😁 |
MKRhere
added a commit
that referenced
this issue
Jun 7, 2022
Add `types` reference also to the `exports` part to fix #1629
This was referenced Jun 7, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Context
Minimal Example Code Reproducing the Issue
With the (as of TS 4.7) released "native Node ESM module" support (activated via
"module": "node16"
) all "telegraf" imports fail with "Could not find a declaration file for module 'telegraf'".This is because in this mode TSC prefers the
"exports"
declaration in telegraf's package.json (and ignores the top-level"types": "./typings/index.d.ts"
). See this answer from the TS team.When locally changing
"exports": { ".":"./lib/index.js" }
to"exports": { ".": { "require": "./lib/index.js", "types": "./typings/index.d.ts" } }
the error disappears. This is also documented here: https://www.typescriptlang.org/docs/handbook/esm-node.htmlShould I propose a PR with this fix?
The text was updated successfully, but these errors were encountered: