-
Notifications
You must be signed in to change notification settings - Fork 22
TypeScript support
Tyler Vigario edited this page Jul 7, 2024
·
5 revisions
Use "moduleResolution": "node16"
or "moduleResolution": "nodenext"
in your tsconfig.json
.
{
"compilerOptions": {
"target": "ES6",
"module": "NodeNext",
"moduleResolution": "nodenext",
},
}
import n2words from 'n2words/i18n/en.js'
console.log(n2words(100)) // "one hundred"
{
"compilerOptions": {
"target": "ES6",
"module": "NodeNext",
"moduleResolution": "nodenext",
},
}
import('n2words/i18n/en.js').then(({default: n2words}) => {
console.log(n2words(100)) // "one hundred"
})
We offer generated typings within our NPM package. There is no need to create your own or use // @ts-ignore
anymore. If you are having trouble with any typings, open an issue here on GitHub; we'll be sure to fix it.
I've created a minimal test repo to proactively monitor the state of importing in TypeScript.