我们想检测(以ESlint或打字稿为例)打字稿中解构参数类型的未使用属性,例如以下示例中的“ 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组件,尽管不再使用它们,但该类型仍需要道具
谢谢
有人在这里为您的用例提出了一个规则建议:https : //github.com/typescript-eslint/typescript-eslint/issues/1529
请享用!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句