问题描述
由于它仍在开发中,因此我试图阻止我的打字稿项目进行类型检查。
我尝试在tsconfig文件中添加"checkJs": false
,但仍然键入检查触发器。我发现的唯一解决方案是在项目的每个文件中添加// @ts-nocheck
。有没有一种方法可以禁用类型检查,而不必将// @ts-nocheck
添加到每个文件中,而是在单个位置使用它。
{
"compilerOptions": {
"target": "es5","checkJs": false,"lib": [
"dom","dom.iterable","esnext"
],"allowJs": true,"skipLibCheck": true,"esModuleInterop": true,"allowSyntheticDefaultImports": true,"strict": true,"forceConsistentCasingInFileNames": true,"module": "esnext","moduleResolution": "node","resolveJsonModule": true,"noUnusedLocals": false,"noUnusedParameters": false,"noEmit": true,"jsx": "preserve","isolatedModules": true
},"include": [
"src"
]
}
解决方法
在您的根目录中创建.eslintrc.js
来忽略您想要的内容或配置eslint
。请阅读docs,其中有很多规则。您的情况:
module.exports = {
extends: ["react-app","plugin:prettier/recommended"],rules: {
"@typescript-eslint/ban-ts-ignore": "off"
},plugins: ["react","@typescript-eslint","prettier"]
};
检查类型