namespaceKeywords
Reports using
modulekeyword instead ofnamespacefor TypeScript namespaces.
✅ This rule is included in the ts stylistic presets.
TypeScript originally used the module keyword to declare internal modules (namespaces).
The namespace keyword was later introduced to avoid confusion with ES6 modules.
Using namespace makes it clear you are defining a TypeScript namespace, not an ES6 module.
Examples
Section titled “Examples”module Values { export const value = 123;}declare module Utils { export function format(input: string): string;}namespace Values { export const value = 123;}declare namespace Utils { export function format(input: string): string;}// String literal module names are allowed (external/ambient module declarations)declare module "external-module" { export const version: string;}When Not To Use It
Section titled “When Not To Use It”If you are working in a codebase that consistently uses module, and migrating to namespace is blocked on tooling issues or finding the time to do it, you may not want this rule.
You might consider using Flint disable comments and/or configuration file disables for those specific situations instead of completely disabling this rule.
Equivalents in Other Linters
Section titled “Equivalents in Other Linters”
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.