英文:
Disable use of 'any' in Ts project?
问题
这是我的当前 tsconfig.json 文件:
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true,
"strictNullChecks": true,
"noUncheckedIndexedAccess": true,
"noImplicitAny": true,
"allowUnreachableCode": false,
"strictFunctionTypes": true
}
}
英文:
Making a React Native app with expo/typescript and since I'm working in a team I want to disable use of type:any since it happened a couple of times someone puts it and forgets to remove it and it doesn't end well usually
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"strict": true,
"strictNullChecks": true,
"noUncheckedIndexedAccess": true,
"noImplicitAny": true,
"allowUnreachableCode": false,
"strictFunctionTypes": true,
},
}
This is my current tsconfig.json
</details>
# 答案1
**得分**: 2
你需要使用`typescript-eslint`中的[`no-explicit-any`][1]!
基本的TypeScript设置中没有这个选项。
[1]: https://typescript-eslint.io/rules/no-explicit-any/
<details>
<summary>英文:</summary>
You'll need the [`no-explicit-any`][1] from `typescript-eslint` !
The basic ts setting doesn't have that option.
[1]: https://typescript-eslint.io/rules/no-explicit-any/
</details>
# 答案2
**得分**: 1
TypeScript本身没有这个设置,但[`typescript-eslint`][1]有一个:[`no-explicit-any`](https://typescript-eslint.io/rules/no-explicit-any)。
[1]: https://typescript-eslint.io
<details>
<summary>英文:</summary>
TypeScript itself doesn't have a setting for that, but [`typescript-eslint`][1] has one: [`no-explicit-any`](https://typescript-eslint.io/rules/no-explicit-any).
[1]: https://typescript-eslint.io
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论