src/content/docs/linter/rules/no-empty-interface.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="TypeScript and TSX" icon="seti:typescript"> ## Summary - Rule available since: `v1.0.0` - Diagnostic Category: [`lint/suspicious/noEmptyInterface`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule has a [**safe**](/linter/#safe-fixes) fix. - The default severity of this rule is [**error**](/reference/diagnostics#error). - Sources: - Inspired from [`@typescript-eslint/no-empty-interface`](https://typescript-eslint.io/rules/no-empty-interface){
"linter": {
"rules": {
"suspicious": {
"noEmptyInterface": "error"
}
}
}
}
Disallow the declaration of empty interfaces.
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.
The rule ignores empty interfaces that extends one or multiple types.
interface A {}
interface A {
prop: string;
}
// Allow empty interfaces that extend a type.
interface B extends A {}
// Allow empty interfaces in ambient modules
declare module "mod" {
interface C {}
}