# @typescript-eslint/consistent-type-definitions

> Require either `interface` or `type` for object types, consistently

You can declare an object's shape with `interface User { ... }` or with `type User = { ... }`. For most code the two work the same. This rule picks one. By default it's `interface`.

The rule only reports a `type` that's an object type. You can't write unions, functions, and other types as an `interface`.

`--fix` rewrites the declaration to the other form.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"@typescript-eslint/consistent-type-definitions" = "error" # or "warn"
```

Every option, set to its default:

```toml bunfig.toml
[lint.rules]
# "interface" or "type"
"@typescript-eslint/consistent-type-definitions" = ["error", "interface"]
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```ts
type User = {
  name: string;
  email: string;
};
```

Not reported:

{/* good */}
```ts
interface User {
  name: string;
  email: string;
}

type Id = string | number;
type Handler = (user: User) => void;
```

## Options

| Option | What it does |
| --- | --- |
| `"interface"` (default) | Report `type User = { ... }`. |
| `"type"` | Report every `interface`. |

{/* bad {"options": ["type"]} */}
```ts
interface User {
  name: string;
}
```

{/* good {"options": ["type"]} */}
```ts
type User = {
  name: string;
};
```

## When not to use it

The two differ in a few ways. Two `interface` declarations with the same name merge, which is how you add to a global type such as `Window`. You can pass a `type` where a `Record<string, unknown>` is expected, but not an `interface`. If your code depends on both, leave this rule off.
