react项目添加typescript类型定义文件 .d.ts

按照网上的办法不生效,需要同步修改ts配置

{
  "compilerOptions": {
    "target": "es6",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext",
      "es2015"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react",
     //这里添加配置
    "baseUrl": "src",
    "typeRoots": [
      "src/custom_types",
      "node_modules/@types"
    ]
  },
  "include": [
    "src"
  ]
}

你可能感兴趣的:(react项目添加typescript类型定义文件 .d.ts)