reactjs - 在 Typescript 的解构参数对象中查找未使用的属性
问题描述
我们想检测(以 ESlint 或 typescript 为例)Typescript 中解构参数类型中未使用的属性,例如以下示例中的“c”
const myIncompletelyRefactoredFunction = ({a, b}: {a: number, b: number, c: number}) => a + b
No-unused-var 允许我们检测以下情况:
//ts-error
const myIncompletelyRefactoredFunction = ({a, b, c}: {a: number, b: number, c: number}) => a + b
但是在这种情况下,重构并不完整,这是我们想要检测的。
我们这里的用例是我们的 React 组件,其中有几十个 props,尽管它们不再使用,但类型仍然需要 props
谢谢
解决方案
有人在这里为您的用例提出了规则建议: https ://github.com/typescript-eslint/typescript-eslint/issues/1529
享受!
推荐阅读
- shell - 将非 PNG 图像复制到 X 剪贴板
- android - 底部溢出 164 像素,在尝试修复热重新加载后,出现未实现的丢失静态目标的处理
- string - 如何在kotlin中将字符串转换为实体
- mysql - 如何将数据表列名称和值重命名为从 infyom laravel 生成器生成的岛名称?
- c++ - CUDA 的性能取决于声明变量
- php - 如何在不刷新页面的情况下将文本和图像文件数据同时发送到 MySQL 数据库
- python-2.7 - 让谷歌计算引擎实例以 64 位运行 Python 2.7.xx?
- c# - 关于扩展方法的困惑
- laravel - 仅在 laravel 中查询 created_at 日期仅等于 carbon::now() 日期
- python - Tkinter 类和按钮使用