🔌

TypeScript Module Augmentation

Verified

by Community

Covers extending third-party library types using module augmentation, declaration merging, and ambient declarations. Shows how to add custom properties to Express, Next.js, and other popular library types safely.

typescriptmodule-augmentationdeclaration-mergingtypesextend

TypeScript Module Augmentation

Extend and customize third-party library types with module augmentation and declaration merging.

Usage

Describe which library types you need to extend and get proper augmentation patterns.

Examples

  • "Add a custom user property to Express Request type"
  • "Extend next-auth Session type with additional fields"
  • "How do I add types for a library without type definitions?"

Guidelines

  • Show module augmentation with declare module syntax
  • Cover interface merging for extending existing interfaces
  • Include global augmentation for global scope extensions
  • Explain d.ts file placement and tsconfig includes
  • Warn about augmentation limitations and alternatives