Visit completeTypeScript roadmap


In TypeScript, namespaces are used to organize and share code across multiple files. Namespaces allow you to group related functionality into a single unit and prevent naming conflicts.

Here’s an example of how you can use namespaces in TypeScript:

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

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

In this example, we use the namespace keyword in the “myNamespace.ts” file to define a namespace “MyNamespace”. Within the namespace, we export a function “doSomething”.

Learn more from the following resources:

Found any mistakes? Help us improve by updating the file here..

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

RoadmapsBest PracticesGuidesVideosFAQsYouTube

roadmap.shbyKamran Ahmed

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

© ·Terms·Privacy·


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