之前为了找到答案花了很多工夫。为了不便和我遇到一样问题的道友,以及我日后的应用。特写一篇短文。
答案很简略,只须要配置下tsconfig.json文件就行了,然而我很道歉的通知各位, 官网配置文档上找不到对应的字段
答案出自官网的文档更新版本 Typescript2.9。
即增加compilerOptions配置项"resolveJsonModule": true即可。我的tsconfig.json如下
{ "compileOnSave": true, "compilerOptions": { "module": "commonjs", "declaration": true, "removeComments": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "allowSyntheticDefaultImports": true, "target": "es2017", "sourceMap": true, "outDir": "./dist", "baseUrl": "./", "incremental": true, "resolveJsonModule": true, }}