persona-community-5/.pnpm-store/v3/files/ee/a91f231918aab5acfce2f4c9230732530ce4304a0afc1c1c40a4d2e68bc7689a27c8a6db4b5d9a7df713c304ba699b86014877fbed02360de3bfac3fa9d764
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

54 lines
1.5 KiB
Plaintext

---
description: "Disallow empty exports that don't change anything in a module file."
---
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-useless-empty-export** for documentation.
An empty `export {}` statement is sometimes useful in TypeScript code to turn a file that would otherwise be a script file into a module file.
Per the [TypeScript Handbook Modules page](https://www.typescriptlang.org/docs/handbook/modules.html):
> In TypeScript, just as in ECMAScript 2015, any file containing a top-level import or export is considered a module.
> Conversely, a file without any top-level import or export declarations is treated as a script whose contents are available in the global scope (and therefore to modules as well).
However, an `export {}` statement does nothing if there are any other top-level import or export statements in a file.
This rule reports an `export {}` that doesn't do anything in a file already using ES modules.
## Examples
<Tabs>
<TabItem value="❌ Incorrect">
```ts
export const value = 'Hello, world!';
export {};
```
```ts
import 'some-other-module';
export {};
```
</TabItem>
<TabItem value="✅ Correct">
```ts
export const value = 'Hello, world!';
```
```ts
import 'some-other-module';
```
</TabItem>
</Tabs>
## When Not To Use It
If you don't mind an empty `export {}` at the bottom of files, you likely don't need this rule.