Skip to main content

TypeScript analyzer

TypeScript Module Augmentation

Surfaces declare-global, module augmentations, ambient module declarations, and global namespace pollution.

patterns ts-module-augmentation

TypeScript Module Augmentation

Surfaces declare-global, module augmentations, ambient module declarations, and global namespace pollution.

Module augmentation (declare global, declare module, ambient *.svg types) is a powerful escape hatch from TypeScript's module system. Used sparingly, it adapts type definitions to project realities; overused, it pollutes the global scope and obscures where definitions originate. This analysis surfaces every augmentation site so the project's global surface can be audited.

Severity guide

info
Module augmentation is intentional and bounded.
warning
Global declarations or high-volume augmentations expand the global namespace beyond what most projects need.
critical
Not currently emitted by this analysis.

Remediation

Limit global declarations to where they are genuinely necessary; prefer module-scoped augmentations and explicit imports.

Limit global declarations to where they are genuinely necessary; prefer module-scoped augmentations and explicit imports.

Documentation