Visit complete TypeScript roadmap

← Back to Topics List

Global Augmentation

In TypeScript, global augmentation is a way to add declarations to the global scope. This is useful when you want to add new functionality to existing libraries or to augment the built-in types in TypeScript.

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

// myModule.d.ts
declare namespace NodeJS {
  interface Global {
    myGlobalFunction(): void;

// main.ts
global.myGlobalFunction = function () {
  console.log('I am a global function!');

myGlobalFunction(); // Output: "I am a global function!"

In this example, we declare a new namespace “NodeJS” and add an interface “Global” to it. Within the “Global” interface, we declare a new function “myGlobalFunction”.

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.