Course contentsShow
← TypeScript
Lesson 1172 of 1,79627. Declaration FilesFree lesson

What Global Augmentation Means

Understanding why and when you need to add types to the global scope in TypeScript projects.

What Global Augmentation Means

You'll learn what "global augmentation" is in TypeScript and why you sometimes need to add types to the global scope.

The Core Idea

Global augmentation is the process of adding type information to TypeScript's global scope — the types that are available everywhere in your project without importing them.

Think of the global scope like the air in a building: it's everywhere, everyone has access to it, and sometimes you need to modify its composition. In TypeScript, certain types exist globally (like Array, Promise, Window), and global augmentation lets you extend or modify these built-in types, or add your own globally-available types.

Why Global Augmentation Exists

Sometimes you need to tell TypeScript about things that exist globally at runtime:

  1. Browser globals you've added via script tags
  2. Global variables injected by your build tool
  3. Runtime environment extensions (like custom properties on window)
  4. Polyfills that add new methods to built-in prototypes

Without global augmentation, TypeScript doesn't know these exist, even though they're actually there at runtime.

When You Need It

You need global augmentation when:

  • A library adds properties to window, global, or other built-in objects
  • Your build process injects global variables
  • You're working with legacy code that uses global namespaces
  • You need runtime-injected configuration available everywhere

Unlike module augmentation (which extends specific imported modules), global augmentation affects the entire TypeScript environment — every file in your project gets access to the augmented types automatically.

Key Takeaway: Global augmentation lets you add or extend types in TypeScript's global scope, making them available everywhere without imports — essential for typing runtime globals your code depends on.