Skip to content

typescript/no-empty-interface Style

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.

Example

ts
interface Foo {}
interface Bar extends Foo {}

How to use

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

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

References

Released under the MIT License.