在打字稿中的变形参数对象中查找未使用的属性

问题描述 投票:3回答:1

[我们想检测(以ESlint或打字稿为例)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组件,尽管不再使用它们,但类型仍然需要道具

谢谢

reactjs typescript eslint destructuring
1个回答
0
投票

有人在这里为您的用例提出了规则建议:https://github.com/typescript-eslint/typescript-eslint/issues/1529

享受!

© www.soinside.com 2019 - 2024. All rights reserved.