-
Notifications
You must be signed in to change notification settings - Fork 10
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
Typescript types don't import correctly when using ESM #45
Comments
Resolved via the latter solution in v1.1.13. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I recently migrated one of my projects from JavaScript to TypeScript, and then from CommonJS to EMCAScript modules (ESM).
While you have added types to cleverbot-free, they do not work correctly when using ESM.
Here is an example of the error I am getting.
As you can see, the type of
cleverbot
is not being imported correctly.I did some research, and found some relevant threads here and here.
It appears that the problem may be fixed by adding
"type": "module"
to package.json so the types can be interpreted as ESM types.I modified cleverbot-free's package.json in the
node_modules
of my project, and it fixed the issue.As you can see, the type is now being imported correctly and TypeScript can compile.
Alternatively, you could also fix the problem by changing
export default cleverbot
toexport = cleverbot
in index.d.ts, but that might not be backwards-compatible to pre-node16 ESM versions? Not sure.Here is an additional resource: https://arethetypeswrong.github.io/?p=cleverbot-free%401.1.12
The text was updated successfully, but these errors were encountered: