module augmentation
Adding types to another package from your own code with declare module "name" { } and declaration merging.
In more detail
It is how you tell TypeScript that Express requests carry a user property added by your authentication middleware. Only merges are allowed; you cannot remove or change existing declarations.
Related terms
- declaration merging — TypeScript combining several declarations with the same name, such as two interface blocks, into one type.
- global augmentation — Adding types to global objects such as Window or NodeJS.ProcessEnv with a declare global { } block inside a module.
- Express — The most widely used web framework for Node.js, providing routing and middleware on top of node:http.
- third-party — Someone other than you and your users, such as an analytics company or a CDN whose code or files your page includes.
Taught in
- Type Aliases Versus Interfaces: Declaration Merging — Production TypeScript
- ECMAScript Modules, CJS Interop And verbatimModuleSyntax — Production TypeScript
- Declaration Files, Ambient Namespaces And Module Augmentation — Production TypeScript