typescript - 如何绕过警告 Unexpected any。指定不同的类型 @typescript-eslint/no-explicit-any

标签 typescript eslint

我们有严格的零 Lint 问题政策。这意味着需要修复所有错误和警告。

在我们的 React typescript 项目中面对这个 lint 错误:

warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any



在 Google 和 lint 网站上搜索。我没有找到这样的解决方案!

试过这个:// eslint:@typescript-eslint/no-explicit-any: "off"这不起作用

有谁知道如何绕过这个eslint React typescript 项目中的规则?

最佳答案

在尝试绕过相同的规则时对我有用的东西,特别是对于重载方法是使用:// eslint-disable-next-line如果您可以简单地在问题行的正上方添加评论。

或者您可以通过以下方式忽略代码的一部分的规则/* eslint-disable rule-name */ your-block-of-code /* eslint-enable rule-name */这里的注释必须是块注释。

关于typescript - 如何绕过警告 Unexpected any。指定不同的类型 @typescript-eslint/no-explicit-any,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58467000/

相关文章:

javascript - Angular2 应用程序未在移动设备上显示加载文本

javascript - Angular 2中的密码确认

reactjs - 'extends: ["airbnb"]' actually do in a React' s eslintrc 文件是什么?

javascript - `undefined!` 在 typescript 中是什么意思?

typescript - mat-option需要2次点击事件来加载异步数据

TypeScript:返回扩展 Record<string, string> 的通用类型的函数

javascript - React Typescript 类型转换问题 - 解析错误 : Missing Semicolon

javascript - 在 ES Lint 中为 React Native 应用程序将 WebSocket 定义为全局变量

javascript - 使用 eslint 强制存储库中的文件夹结构和名称

javascript - 类型错误 : Cannot read property 'setState' of undefined using event