Skip to main content

prefer-namespace-keyword

Require using namespace keyword over module keyword to declare custom TypeScript modules.

In an effort to prevent further confusion between custom TypeScript modules and the new ES2015 modules, starting with TypeScript v1.5 the keyword namespace is now the preferred way to declare custom TypeScript modules.

Attributes

  • Included in configs
    • ✅ Recommended
    • 🔒 Strict
  • Fixable
    • 🔧 Automated Fixer
    • 🛠 Suggestion Fixer
  • 💭 Requires type information

Rule Details

This rule aims to standardize the way modules are declared.

When Not To Use It

If you are using the ES2015 module syntax, then you will not need this rule.

Options

// .eslintrc.json
{
"rules": {
"@typescript-eslint/prefer-namespace-keyword": "error"
}
}

This rule is not configurable.

Further Reading