consistent-type-definitions
Configuration
Rule Details
Enforce type definitions to consistently use either interface or type. TypeScript provides two ways to define object types: interface declarations and type alias declarations with object literal types. This rule enforces one style for consistency.
The rule supports two modes: "interface" (default) prefers interfaces over type literals, and "type" prefers type aliases over interfaces.
This rule is auto-fixable.
Examples of incorrect code for this rule (with default "interface" option):
Examples of correct code for this rule (with default "interface" option):
Examples of incorrect code for this rule (with "type" option):
Examples of correct code for this rule (with "type" option):
Autofix
The rule provides automatic fixes:
interfacemode: Convertstype T = { ... }tointerface T { ... }, handlingexport,declare, type parameters, parenthesized types, and trailing semicolons.typemode: Convertsinterface T { ... }totype T = { ... }, convertingextendsclauses to intersection types (& B & C). Handlesexport default interfaceby splitting into a type declaration and a separate default export.
Note: Interfaces inside declare global blocks report an error but are not auto-fixed to avoid breaking global type augmentation patterns.