Avo*_*ion 9 typescript reactjs create-react-app
"exclude": ["*.test.ts", "*.test.tsx"]tsconfig 中仅阻止测试特定类型的类型检查(例如,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"]
}
Run Code Online (Sandbox Code Playgroud)
我最终选择了另一个问题中列出的禁用每个文件选项
如果您的测试全部位于 1 个文件夹中,您可以尝试排除该文件夹,或者禁用该线程中也列出的 .js 文件扩展名。
| 归档时间: |
|
| 查看次数: |
7223 次 |
| 最近记录: |