Skip to content
← Back to rules

typescript/no-empty-interface Style

🚧 An auto-fix is planned for this rule, but not implemented at this time.

What it does

Disallow the declaration of empty interfaces.

Why is this bad?

An empty interface in TypeScript does very little: any non-nullable value is assignable to {}. Using an empty interface is often a sign of programmer error, such as misunderstanding the concept of {} or forgetting to fill in fields. This rule aims to ensure that only meaningful interfaces are declared in the code.

Examples

Examples of incorrect code for this rule:

ts
interface Foo {}
interface Bar extends Foo {}

Examples of correct code for this rule:

ts
interface Foo {
  member: string;
}
interface Bar extends Foo {
  member: string;
}

Configuration

This rule accepts a configuration object with the following properties:

allowSingleExtends

type: boolean

default: false

When set to true, allows empty interfaces that extend a single interface.

How to use

To enable this rule using the config file or in the CLI, you can use:

json
{
  "rules": {
    "typescript/no-empty-interface": "error"
  }
}
bash
oxlint --deny typescript/no-empty-interface

References