美文网首页
react项目添加typescript类型定义文件 .d.ts

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

作者: 8d2855a6c5d0 | 来源:发表于2022-02-19 14:15 被阅读0次

按照网上的办法不生效,需要同步修改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

      本文链接:https://www.haomeiwen.com/subject/nihplrtx.html