-
Notifications
You must be signed in to change notification settings - Fork 22
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
language specific files in TypeScript #109
Comments
I get the following error at runtime:
|
@ludans Looks like a CommonJS environment. Does switching to dynamic import work? // @ts-ignore
import('n2words/i18n/EN').then(n2words => {
n2words.default(100)
}) |
I just use an
This is my
|
@ludans Adding {
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "nodenext"
},
} import('n2words/i18n/EN.js').then(({ default: n2words }) => {
console.log(n2words(100));
}); However, I noticed that my export of the i18n languages is not working as intended. Going to send a PR shortly to fix that. |
@ludans The exports issue has been resolved in the latest release (1.16.2). Please let me know if the new release and the instructions in my previous comment help. Thanks for reporting! EDIT: I've created a minimal test repo so I can proactively monitor the state of importing in TypeScript. You can check it out here. |
thanks |
Cheers! I've added typings in #112 which is included in |
Hello,
I am trying to use language specific files, as described in https://github.com/forzagreen/n2words/wiki/Importing-only-specific-languages
In a typescript file, this statement does not work:
import n2words from 'n2words/i18n/EN';
I get this error:
Impossible de localiser le module 'n2words/i18n/EN' ou les déclarations de type correspondantes.ts(2307)
If I use:
import n2words from 'n2words/lib/i18n/EN';
, I can compile, but I can an error at runtime:Package subpath './lib/i18n/EN' is not defined by "exports" in ... \node_modules\n2words\package.json
Could you please detail how to use this new packaging with TypeScript?
The text was updated successfully, but these errors were encountered: