typescript - 我的项目有 tsx 和 ts 文件,但我想在测试文件中禁用 ts
问题描述
我想在我的测试文件中禁用 TS。测试文件扩展名为 .test.tsx。我尝试禁用 TS 检查,但尽管有下面的代码,TS 仍然抱怨。
"exclude": ["**/*.test.tsx", "**/*.test.ts"]
有谁知道如何在 test.tsx 中成功禁用 TS?在我不想被 TS 检查的文件上使用 .tsx 扩展名是错误的吗?
当我将扩展名更改为 .js 时,一切都按预期工作,但是当所有其他文件都与 ts 相关时突然引入 .js 很奇怪。
tsconfi.gjson
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"types": [
"node",
"@testing-library/jest-dom",
]
},
"include": ["src"],
"exclude": ["**/*.test.tsx", "**/*.test.ts"]
}
解决方案
推荐阅读
- c# - 从 Unloaded 事件处理程序引发的 RoutedEvent 未冒泡
- postgresql - 双引号在更新查询中给出问题
- javascript - 用百分比计算器创建一个整数
- sql - 如何将亚马逊卖家报告上传到 SQL 数据库?
- python - 将量化的 Pytorch 模型导出到 onnx 时出现分段错误
- android - 在特定时间关闭 App 时安排 Android 功能
- f# - 任何地方都有 option<> 计算表达式吗?
- python - 最大子数组总和 - 我的解决方案哪里错了?Kadane 算法
- c# - Google API Explorer 不会创建 Compute Engine 虚拟机实例
- java - junit 5 自定义参数化测试