Rule: no-any

Disallows usages of any as a type declaration.

Rationale

Using any as a type declaration nullifies the compile-time benefits of the type system.

If you’re dealing with data of unknown or “any” types, you shouldn’t be accessing members of it. Either add type annotations for properties that may exist or change the data type to the empty object type {}.

Alternately, if you’re creating storage or handling for consistent but unknown types, such as in data structures or serialization, use <T> template types for generic type handling.

Also see the no-unsafe-any rule.

Notes:
TS Only

Config

If "ignore-rest-args": true is provided rest arguments will be ignored.

Config examples
"no-any": true
"no-any": [true, {"ignore-rest-args": true}]
Schema
{
  "type": "object",
  "properties": {
    "ignore-rest-args": {
      "type": "boolean"
    }
  }
}

Code examples:

Disallows usages of `any` as a type declaration.
"rules": { "no-any": true }
Passes
let foo: object;
Fails
let foo: any;
Disallows usages of `any` as a type declaration except rest spread parameters.
"rules": { "no-any": [true, { "ignore-rest-args": true }] }
Passes
function foo(a: number, ...rest: any[]): void {
    return;
}