A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://typescript-eslint.io/rules/no-empty-interface/ below:

no-empty-interface | typescript-eslint

no-empty-interface

Disallow the declaration of empty interfaces.

💡

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

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"
}
});

.eslintrc.cjs

module.exports = {
"rules": {
"@typescript-eslint/no-empty-interface": "error"
}
};

Try this rule in the playground ↗

Examples

interface Foo {
name: string;
}


interface Bar {
age: number;
}



interface Baz extends Foo, Bar {}
Open in Playground Options

This rule accepts the following options:

type Options = [
{

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4