We have a strict zero lint issues policy. This means all errors and warnings need to be fixed.
Facing this lint error in our React typescript project:
warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
Searched on Google and on the lint website. I didn't find a solution as such!
Tried this: // eslint:@typescript-eslint/no-explicit-any: "off"
which is not working
Does anyone know how to bypass this eslint
rule in a React typescript project?
If you are using ESLint and you need to disable the next line, use this code: eslint-disable-next-line.
Rule DetailsThis rule doesn't allow any types to be defined. It aims to keep TypeScript maximally useful. TypeScript has a compiler flag for --noImplicitAny that will prevent an any type from being implied by the compiler, but doesn't prevent any from being explicitly used.
Something that works for me when trying to bypass the same rule, specially for overloading methods is to use: // eslint-disable-next-line
if you can simply just add a comment right above the line with the issue.
Or you can ignore the rule for just a section of the code by /* eslint-disable rule-name */ your-block-of-code /* eslint-enable rule-name */
The comments here must be block comments.
Can you use unknown
? e.g. HttpResponse<unknown>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With