如何用TypeScript正确读取json文件?

0 人关注

错误 TS2732:无法找到模块 '.../service-. .json'。考虑使用'--resolveJsonModule'来导入带有'.json'的模块。

import serviceAccountPlay from '../service-account.json';

我有这个模块 文件名 -> typing.d.ts

   declare module "*.json" {
    const value: any;
    export default value;

tsconfig.json

   tsconfig.json
      "compilerOptions": {
     "module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": false,
"outDir": "lib",
"sourceMap": true,
"strict": false,
"resolveJsonModule": true,
"esModuleInterop": true,
 "target": "es2017"
 "compileOnSave": true,
 "include": [
  "src"