首页 文章

TypeScript - isolatedModules和JSON导入

提问于
浏览
5

我们使用Babel来编译我们的TypeScript文件,我们想在tsconfig.json中使用isolatedModules:true,因为它是推荐的方式 . 例如,当您尝试重新导出接口时,它会引发错误 . 这是一个必要的功能,因为Babel TypeScript编译器也不允许这样做 .

但是,我们需要在TS文件中导入JSON文件 . 问题是tsc会抛出以下错误:

Cannot compile namespaces when the '--isolatedModules' flag is provided.

知道如何导入JSON并保持类型检查器满意吗?

1 回答

相关问题