【发布时间】:2020-04-21 17:23:49
【问题描述】:
tsconfig 中的
"exclude": ["*.test.ts", "*.test.tsx"] 仅阻止对测试特定类型(例如 describe、it、expect 等)的类型检查。我仍然在 vscode 的每个测试文件中看到导入组件的错误。禁用这些导入组件错误的唯一方法是在每个测试文件的开头使用//@ts-nocheck。
有没有办法禁用 tsconfig 中所有测试文件的所有类型检查,包括从非测试文件中导入的任何组件?
完整的tsconfig.json 文件(创建 React App 项目)
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"noImplicitAny": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react"
},
"include": ["src"],
"exclude": ["*.test.ts", "*.test.tsx"]
}
【问题讨论】:
-
嗨,你找到解决办法了吗?
-
您找到解决方案了吗???
-
请看我的主要答案@Darvesh
-
请看我的主要答案@DariusV
标签: reactjs typescript create-react-app