我们使用Babel来编译我们的TypeScript文件,我们想在tsconfig.json中使用isolatedModules:true,因为它是推荐的方式 . 例如,当您尝试重新导出接口时,它会引发错误 . 这是一个必要的功能,因为Babel TypeScript编译器也不允许这样做 .
但是,我们需要在TS文件中导入JSON文件 . 问题是tsc会抛出以下错误:
Cannot compile namespaces when the '--isolatedModules' flag is provided.
知道如何导入JSON并保持类型检查器满意吗?
1 回答
这是一个TypeScript错误,修复程序刚刚合并为master:https://github.com/Microsoft/TypeScript/pull/28207
它应该在3.1.4上提供 .