You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 to export = cleverbot in index.d.ts, but that might not be backwards-compatible to pre-node16 ESM versions? Not sure.
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: