Introduction

Completed

TypeScript provides two ways to organize code: Namespaces and modules. This module explains how to organize TypeScript code using namespaces. While both namespaces and modules provide a way to categorize related code in meaningful ways and help you control which code is exposed to the global namespace of your applications, there are some differences between them.

Learning objectives

  • Explain the purpose of namespaces.
  • Implement single-file namespaces.
  • Implement multi-file namespaces.
  • Explain the design considerations for using namespaces and modules.

Prerequisites

  • Knowledge of TypeScript
  • Familiarity with JavaScript
  • Installed software:
    • Git

    • Visual Studio Code

    • Node.js

    • TypeScript - TypeScript can be installed after installing Node.js after running the following in a terminal or command window:

      npm install -g typescript
      

For best results, follow the complete instructions for setting up your environment and using the TypeScript compiler in Module 01: Get started with TypeScript. After setting up your environment, you can run any of the Lab setup or solution files in the Build JavaScript applications by using TypeScript learning path.