no-implicit-any-catch
Disallow usage of the implicit
anytype in catch clauses.
This rule has been deprecated as TypeScript versions >=4 includes a useUnknownInCatchVariables compiler option with the same check.
TypeScript 4.0 added support for adding an explicit any or unknown type annotation on a catch clause variable.
By default, TypeScript will type a catch clause variable as any, so explicitly annotating it as unknown can add a lot of safety to your codebase.
The noImplicitAny flag in TypeScript does not cover this for backwards compatibility reasons, however you can use useUnknownInCatchVariables (part of strict) instead of this rule.
Attributes
- Included in configs
- ✅ Recommended
 - 🔒 Strict
 
 - Fixable
- 🔧 Automated Fixer
 - 💡 Suggestion Fixer
 
 - 💭 Requires type information
 
DEPRECATED
Rule Details
This rule requires an explicit type to be declared on a catch clause variable.
Examples of code for this rule:
- ❌ Incorrect
 - ✅ Correct
 
try {
  // ...
} catch (e) {
  // ...
}
try {
  // ...
} catch (e: unknown) {
  // ...
}
module.exports = {
  "rules": {
    "@typescript-eslint/no-implicit-any-catch": "warn"
  }
};
Options
This rule accepts an options object with the following properties:
interface Options {
  /**
   * Whether to disallow specifying `: any` as the error type as well. See also `no-explicit-any`.
   */
  allowExplicitAny?: boolean;
}
const defaultOptions: Options = [{ allowExplicitAny: false }];
allowExplicitAny
The follow is is not considered a warning with { allowExplicitAny: true }
try {
  // ...
} catch (e: any) {
  // ...
}
When Not To Use It
If you are not using TypeScript 4.0 (or greater), then you will not be able to use this rule, annotations on catch clauses is not supported.