Issue
I have the "noImplicitAny": true, flag in tsconfig.json, and "@typescript-eslint/no-explicit-any": 2, in place for eslint, but they don't catch things like
type BadInterface {
property: any
}
Are there any configuration options through tsconfig, or eslint to flag this? Our team's contractors use any for lots of properties in interfaces, and I can't seem to find a way to prevent this from passing tsc or eslint commands in the CI workflow.
To just be completely clear, I want something to let me know when someone uses type any for a key on an interface or type. It seems to be fine when TS is inferring the type from an any, but I want it blow up when someone tries to use any as a type anywhere.
Solution
I believe you can use the ban-types rule to prevent explicit use of any.
For example:
"@typescript-eslint/ban-types": [
2,
{
"types": {
"any": "Don't use 'any' because it is unsafe",
},
"extendDefaults": true,
}
}
Answered By - SMHutch
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.