Skip to content

typescript/consistent-type-definitions Style

🛠️ An auto-fix is available for this rule.

What it does

Enforce type definitions to consistently use either interface or type.

Why is this bad?

TypeScript provides two common ways to define an object type: interface and type. The two are generally very similar, and can often be used interchangeably. Using the same type declaration style consistently helps with code readability.

Example

ts
// incorrect, when set to "interface"
type T = { x: number };

// incorrect when set to "type"
interface T {
  x: number;
}

References

Released under the MIT License.