src/content/docs/linter/rules/use-namespace-keyword.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/useNamespaceKeyword`](/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: - Same as [`@typescript-eslint/prefer-namespace-keyword`](https://typescript-eslint.io/rules/prefer-namespace-keyword){
"linter": {
"rules": {
"suspicious": {
"useNamespaceKeyword": "error"
}
}
}
}
Require using the namespace keyword over the module keyword to declare TypeScript namespaces.
TypeScript historically allowed a code organization called namespace.
ECMAScript modules are preferred (import / export).
For projects still using namespaces, it's preferred to use the namespace keyword instead of the module keyword.
The module keyword is deprecated to avoid any confusion with the ECMAScript modules which are often called modules.
Note that TypeScript module declarations to describe external APIs (declare module "foo" {}) are still allowed.
See also: https://www.typescriptlang.org/docs/handbook/namespaces-and-modules.html
module Example {}
namespace Example {}
declare module "foo" {}