persona-community-5/.pnpm-store/v3/files/12/1673a76f10a450eaf799623c0f70c3636c31a5db874e087a78fbc6e7cbf9b123310725a931e3d6ac57c61c220f0852ad45bef363c3db4b5c803f19e211edf0
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

52 lines
1.5 KiB
Plaintext

---
description: 'Require using `namespace` keyword over `module` keyword to declare custom TypeScript modules.'
---
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/prefer-namespace-keyword** for documentation.
TypeScript historically allowed a form of code organization called "custom modules" (`module Example {}`), later renamed to "namespaces" (`namespace Example`).
Namespaces are an outdated way to organize TypeScript code.
ES2015 module syntax is now preferred (`import`/`export`).
For projects still using custom modules / namespaces, it's preferred to refer to them as namespaces.
This rule reports when the `module` keyword is used instead of `namespace`.
> This rule does not report on the use of TypeScript module declarations to describe external APIs (`declare module 'foo' {}`).
## Examples
<Tabs>
<TabItem value="❌ Incorrect">
```ts
module Example {}
```
</TabItem>
<TabItem value="✅ Correct">
```ts
namespace Example {}
declare module 'foo' {}
```
</TabItem>
</Tabs>
## When Not To Use It
If you are not using TypeScript's older `module`/`namespace` keywords, then you will not need this rule.
## Further Reading
- [Modules](https://www.typescriptlang.org/docs/handbook/modules.html)
- [Namespaces](https://www.typescriptlang.org/docs/handbook/namespaces.html)
- [Namespaces and Modules](https://www.typescriptlang.org/docs/handbook/namespaces-and-modules.html)