Visit complete TypeScript roadmap

← Back to Topics List


In TypeScript, modules are used to organize and reuse code. There are two types of modules in TypeScript:

  • Internal
  • External

Internal modules are used to organize code within a file and are also referred to as namespaces. They are defined using the “namespace” keyword.

External modules are used to organize code across multiple files. They are defined using the “export” keyword in one file and the “import” keyword in another file. External modules in TypeScript follow the CommonJS or ES modules standards.

Here is an example of how you can use internal modules in TypeScript:

// myModule.ts
namespace MyModule {
  export function doSomething() {
    console.log('Doing something...');

// main.ts
/// <reference path="myModule.ts" />
MyModule.doSomething(); // Output: "Doing something..."

Learn more from the following links:

Community is the 6th most starred project on GitHub and is visited by hundreds of thousands of developers every month.

Roadmaps Best Practices Guides Videos Store YouTube by Kamran Ahmed

Community created roadmaps, articles, resources and journeys to help you choose your path and grow in your career.

© · FAQs · Terms · Privacy


The leading DevOps resource for Kubernetes, cloud-native computing, and the latest in at-scale development, deployment, and management.