We are using a Babel to compile our TypeScript files and we want to use isolatedModules: true in our tsconfig.json as it is a recommended way. It, for example, throws an error when you try to re-export an interface. This is a necessary feature as Babel TypeScript compiler doesn't allow that too.
However, we need to import a JSON file in our TS file. The issue is that tsc will throws the following error:
Cannot compile namespaces when the '--isolatedModules' flag is provided.
Any idea how to import a JSON and keep type-checker happy?
This was a TypeScript bug and the fix was just merged to master: https://github.com/Microsoft/TypeScript/pull/28207
It should be available on 3.1.4+.
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