Content-Length: 77559 | pFad | https://typescript-eslint.io/rules/no-empty-interface/

no-empty-interface | typescript-eslint
Skip to main content

no-empty-interface

Disallow the declaration of empty interfaces.

🔧

Some problems reported by this rule are automatically fixable by the --fix ESLint command line option.

💡

Some problems reported by this rule are manually fixable by editor suggestions.

Deprecated

This rule has been deprecated in favour of the more comprehensive @typescript-eslint/no-empty-object-type rule.

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.

eslint.config.mjs
export default tseslint.config({
rules: {
"@typescript-eslint/no-empty-interface": "error"
}
});

Try this rule in the playground ↗

Examples

// 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 {}
Open in Playground

Options

This rule accepts the following options:

type Options = [
{
/** Whether to allow empty interfaces that extend a single other interface. */
allowSingleExtends?: boolean;
},
];

const defaultOptions: Options = [{ allowSingleExtends: false }];

allowSingleExtends

Whether to allow empty interfaces that extend a single other interface. Default: 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.

Resources









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://typescript-eslint.io/rules/no-empty-interface/

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy