Skip to main content

Modules and Namespaces

Namespaces

0:00
LearnStep 1/2

Namespaces

Namespaces (Legacy)

Namespaces were TypeScript's original way to organize code:

typescript

When to Use Namespaces

  • Legacy code migration
  • Global scripts (no module system)
  • Declaration merging with external libraries

Prefer Modules

typescript

Recommendation: Use ES modules for new code. Namespaces are mainly for maintaining older TypeScript codebases.