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 import error on node #73
Comments
Typescript is currently tested with imports. Would you be able to share your |
You example is reproduceable . I just download you code , then run
|
Thanks! I see the issue now. The typescript definition file seems to be correct, but typescript is attempting to import the commonjs module instead of the ES6 module. I want to investigate further to find the proper solution, but in the short term you should be able to use one of the following imports:
or
|
If I use import * as like this: import * as currency from 'currency.js'; tsc will throw error I think the cjs module should change to But I don't know how to realize this on rollup, So I can't to send pr to fix this. |
So here's the root of the issue. Typescript is assuming modules export a default, which can cause issues when importing cjs modules. As such, there seems to be only 3 possible solutions:
I updated the typescript definition file to allow for the first 2 statements to be used, which I should hopefully be releasing in a patch update soon. |
I import this package like this:
This code work fine on webpack build, but fail on node
TypeError: currency_js_1.default is not a function
. I use currency.js in TypeScript project.The npm package source exports is
module.exports = currency
, which should beexport = currency;
in d.ts file. So, I think maybe we should modify the currency.d.ts , or build result.The text was updated successfully, but these errors were encountered: