目录

@typescript-eslint/no-explicit-any

Disallow the any type.

This rule applies only to .js and .ts files.

Rule Configuration

// code-linter.json5
{
  "rules": {
    "@typescript-eslint/no-explicit-any": "error"
  }
}

Options

For details, see @typescript-eslint/no-explicit-any.

Example of Correct Code

export const age1 = 17;
export const age2 = [age1];
export const age3 = [age1];

export function greet1(): string {
  return 'greet';
}

export function greet2(): string[] {
  return ['greet'];
}

export function greet4(): string[][] {
  return [['greet']];
}

export function greet5(param: readonly string[]): string {
  return param[age1];
}

export function greet6(param: readonly string[]): string[] {
  return [...param];
}

Example of Incorrect Code

export const age1: any = 17;
export const age2: any = [age1];
export const age3: any = [age1];

export function greet1(): any {
  return 'greet';
}

export function greet2(): any[] {
  return ['greet'];
}

export function greet4(): any[][] {
  return [['greet']];
}

export function greet5(param: readonly any[]): any {
  return param[age1];
}

export function greet6(param: readonly any[]): any[] {
  return [...param];
}

Rule Set

plugin:@typescript-eslint/recommended
plugin:@typescript-eslint/all

For details about how to configure Code Linter check rules, see Code Linter.