Closed Sergiobop closed 1 year ago
Thank you for reporting this! This is most likely caused by something in #105.
I'm not 100% familiar with TypeScript but I think there are some type file requirements which could be an issue here as well. I'm just not sure why it worked before from source but not anymore. I'll throw the new version in a blank TypeScript project after work and see what I find.
In the meantime I found this article which may be helpful - https://askjavascript.com/cannot-find-module-and-its-corresponding-type-declarations/
@Sergiobop I could get around this TypeScript issue by preceding the import line with // @ts-ignore
. See the example below and let me know if this works for you as well.
// @ts-ignore
import n2words from 'n2words/i18n/ES'
console.log(n2words)
I'll look into providing a proper type definition file for TypeScript users.
@TylerVigario Great, thank you for your fast response
Awesome package btw!
@Sergiobop We thank you for your kind words! Going to close this for now but will follow up if, and when, I add proper TypeScript definitions.
@Sergiobop I've gone into further discussion in #109 and created a wiki for importing in TypeScript - https://github.com/forzagreen/n2words/wiki/Importing-in-TypeScript
Thank you @TylerVigario , i endep up importing the library like this:
// @ts-ignore import n2wordsES from 'n2words/i18n/es.js';
And it's working
@Sergiobop I've added typings in #112 which is included in v1.16.3
. // @ts-ignore
should no longer be needed. Cheers!
After upgrading to 1.16.1 i can't import specific languages:
From the wiki: import n2wordsES from 'n2words/i18n/ES.js'
If i change the import to import n2wordsES from 'n2words/lib/i18n/ES.js';
Error: Module not found: Error: Package path ./lib/i18n/ES.js is not exported from package node_modules/n2words (see exports field in node_modules/n2words/package.json)
Downgrading to 1.15 since it works as spected:
import n2wordsES from 'n2words/lib/i18n/ES.mjs'
-> Works in 1.15