# @typescript-eslint/no-empty-object-type

> Disallow the `{}` type and empty interfaces

`{}` doesn't mean "an object with no properties". It accepts every value except `null` and `undefined`, so `0`, `""` and `[]` all pass. An interface with no members behaves the same way. Use `object` for "any object", `unknown` for "any value", and `Record<string, never>` for an object that has no properties.

An empty interface that extends one other type is reported too, because it's only a second name for that type.

`{}` in an intersection, such as `T & {}`, isn't reported. There it's a way to remove `null` and `undefined` from `T`.

This rule is on by default in TypeScript files.

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

## Configure

On by default as a warning. To turn it off:

```toml bunfig.toml
[lint.rules]
"@typescript-eslint/no-empty-object-type" = "off" # or "error"
```

Every option, set to its default. The ones that are commented out are unset by default.

```toml bunfig.toml
[lint.rules]
"@typescript-eslint/no-empty-object-type" = ["warn", {
  allowInterfaces = "never", # "always", "never" or "with-single-extends"
  allowObjectTypes = "never", # "always" or "never"
  # allowWithName = <string>,
}]
```

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

## Examples

Reported:

{/* bad {"count": 2} */}
```ts
let settings: {} = 42; // no type error

interface Props {}
```

Not reported:

{/* good */}
```ts
let settings: object = { theme: "dark" };
let payload: unknown = 42;
let nothing: Record<string, never> = {};

type Defined<T> = T & {};
```

## Options

| Option | Default | What it does |
| --- | --- | --- |
| `allowInterfaces` | `"never"` | `"always"` allows every empty interface. `"with-single-extends"` allows one that extends one type. |
| `allowObjectTypes` | `"never"` | `"always"` allows the `{}` type. |
| `allowWithName` | none | A regular expression. An empty interface, or a type alias for `{}`, is allowed if its name matches. |

{/* good {"options": [{"allowInterfaces": "with-single-extends"}]} */}
```ts
interface User {
  name: string;
}

interface Admin extends User {}
```

With `allowWithName`, you can allow a component's empty props and nothing else:

{/* good {"options": [{"allowWithName": "Props$"}]} */}
```ts
interface HeaderProps {}

type FooterProps = {};
```

{/* bad {"options": [{"allowWithName": "Props$"}]} */}
```ts
interface HeaderState {}
```
