Some JS libraries (e.g. https://www.npmjs.com/package/winston) require json files in their code (the most common use case being package.json). Typescript will throw an error when importing such libraries, as it only understand .ts and .tsx.
Can we teach typescript how to handle importing json files like the way node handles it?
TS 2.9 added support for json imports. Just add:
{
"compilerOptions": {
"resolveJsonModule": true
}
}
in your tsconfig.json or jsconfig.json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With