Skip to content

typescript/no-namespace Restriction

What it does

Disallow TypeScript namespaces.

Why is this bad?

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).

Example

typescript
module foo {}
namespace foo {}
declare module foo {}
declare namespace foo {}

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny typescript/no-namespace
json
{
  "rules": {
    "typescript/no-namespace": "error"
  }
}

References

Released under the MIT License.