Skip to main content

no-empty-interface

Disallows the declaration of empty interfaces.

An empty interface is equivalent to its supertype. If the interface does not implement a supertype, then the interface is equivalent to an empty object ({}). In both cases it can be omitted.

Attributes

  • Included in configs
    • ✅ Recommended
    • 🔒 Strict
  • Fixable
    • 🔧 Automated Fixer
    • 🛠 Suggestion Fixer
  • 💭 Requires type information

Rule Details

This rule aims to ensure that only meaningful interfaces are declared in the code.

// an empty interface
interface Foo {}

// an interface with only one supertype (Bar === Foo)
interface Bar extends Foo {}

// an interface with an empty list of supertypes
interface Baz {}

Options

This rule accepts a single object option with the following default configuration:

{
"@typescript-eslint/no-empty-interface": [
"error",
{
"allowSingleExtends": false
}
]
}
  • allowSingleExtends: true will silence warnings about extending a single interface without adding additional members

When Not To Use It

If you don't care about having empty/meaningless interfaces, then you will not need this rule.