问题描述
我在tsconfig.json中有"noImplicitAny": true,
标志,并且有"@typescript-eslint/no-explicit-any": 2,
属于eslint,但它们没有捕捉到类似的东西
type BadInterface {
property: any
}
是否有通过tsconfig或eslint进行标记的配置选项?我们团队的承包商使用any
来获取界面中的许多属性,我似乎找不到一种方法来阻止它在CI工作流程中传递tsc
或eslint
命令。>
为完全清楚起见,当有人在界面或类型上使用类型any
作为键时,我想让我知道。 TS从any
推断类型似乎很好,但是当有人尝试在任何地方使用any
作为类型时,我希望它爆炸。
解决方法
我相信您可以使用ban-types
规则来防止显式使用any
。
例如:
"@typescript-eslint/ban-types": [
2,{
"types": {
"any": "Don't use 'any' because it is unsafe",},"extendDefaults": true,}
}