目录

@typescript-eslint/prefer-ts-expect-error

Enforce using @ts-expect-error over @ts-ignore.

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

Rule Configuration

// code-linter.json5
{
  "rules": {
    "@typescript-eslint/prefer-ts-expect-error": "error"
  }
}

Options

This rule is not configurable.

Example of Correct Code

// @ts-expect-error: with description
export const str: string = 1;

/**
 * Explaining comment
 *
 * @ts-expect-error: with description */
export const multiLine: number = 'value';

/** @ts-expect-error: with description */
export const block: string = 1;

Example of Incorrect Code

// @ts-ignore
const str: string = 1;

/**
 * Explaining comment
 *
 * @ts-ignore */
const multiLine: number = 'value';

/** @ts-ignore */
const block: string = 1;

const isOptionEnabled = (key: string): boolean => {
  // @ts-ignore: if key isn't in globalOptions it'll be undefined which is false
  return !!globalOptions[key];
};

Rule Set

plugin:@typescript-eslint/all

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