persona-community-5/.pnpm-store/v3/files/20/53cdbcc3d920d5019218d5cfe0940bc9da58f9e3a50cac2d17614f9045dbf929cc7ad65f9b09f0652f7ed926ee5cef2d3ff8f50d1bf7a71f085c855103473e
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

64 lines
1.5 KiB
Plaintext

---
description: 'Disallow the declaration of empty interfaces.'
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/no-empty-interface** for documentation.
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.
## Examples
<Tabs>
<TabItem value="❌ Incorrect">
```ts
// 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 {}
```
</TabItem>
<TabItem value="✅ Correct">
```ts
// an interface with any number of members
interface Foo {
name: string;
}
// same as above
interface Bar {
age: number;
}
// an interface with more than one supertype
// in this case the interface can be used as a replacement of an intersection type.
interface Baz extends Foo, Bar {}
```
</TabItem>
</Tabs>
## Options
### `allowSingleExtends`
`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.