目录

@typescript-eslint/consistent-type-definitions

Enforce type definitions to consistently use either interface or type.

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

Rule Configuration

// code-linter.json5
{
  "rules": {
    "@typescript-eslint/consistent-type-definitions": "error"
  }
}

Options

For details, see @typescript-eslint/consistent-type-definitions.

Example of Correct Code

// The definition of a basic type can use type.
export type T1 = string;

// By default, you are advised to define an object type as interface.
export interface T2 {
  x: number;
}

export type Foo = string | T2;

Example of Incorrect Code

// By default, you are advised to define an object type as interface.
type T = { x: number };

Rule Set

plugin:@typescript-eslint/all

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