Free tools Windows power users keep installed
One-click scans. No signup required.
Use extends when you want a new interface to inherit members from one or more base interfaces. Use declaration merging when separate declarations with the same name are intentionally meant to contribute to one existing interface—most often to describe a library or global capability that already exists at runtime.
Extension and declaration merging solve different problems
Interface extension creates a distinct type with a distinct name. The derived interface includes the members of its base interface, while remaining a separate contract you can use where appropriate.
interface Identified {
id: string;
}
interface User extends Identified {
displayName: string;
}
Here, User has both id and displayName; Identified remains unchanged. An interface can extend multiple interfaces when the new contract should compose their members. See the TypeScript interfaces documentation.
Declaration merging instead combines separate declarations that use the same interface name into one definition. The TypeScript Handbook defines it as the compiler merging “two separate declarations declared with the same name into a single definition.” In practice, this lets a declaration contribute members to an existing named interface rather than create a new derived interface. See Declaration Merging.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →#1 Best Overall
Choose the mechanism that matches the type you need
| Situation | Use | Why |
|---|---|---|
| You own a new API shape and want to reuse members while keeping a distinct contract. | Interface extension | A new interface name makes the relationship explicit without changing every use of the base interface. |
| A third-party module adds a runtime capability, and its named export’s published type does not describe it. | Module augmentation | It adds type information to the existing exported declaration. The runtime patch must be supplied separately. |
| A runtime library or environment adds a global capability that needs type support. | Global augmentation | It describes the added global member to TypeScript; the corresponding runtime behavior must already exist independently. |
| You are composing or specializing a type in code you control, rather than deliberately adding to a shared existing name. | Usually interface extension | A separately named interface avoids silently altering the shape seen by all users of a merged name. |
When declaration merging is the right choice
Augment a named module export
Use module augmentation when a module’s existing named export needs additional type information—for example, when a plugin adds a method to a library object at runtime. The augmentation must target the module using a specifier TypeScript resolves through normal import/export module resolution. It contributes to an existing declaration; it does not create a new top-level declaration.
The Handbook’s Observable<T> example illustrates the separation between types and implementation: the example augments the named Observable export with a map method, then separately assigns Observable.prototype.map in JavaScript. The declaration tells the compiler about the method; it does not install the method. Module augmentation also cannot augment a default export.
Rank #2
- TypeScript implements a superset of syntax for strictly typed development, facilitating deep static analysis and enhanced development environment integration. The compiler translates source into standard script formats, ensuring parity across any runtime.
- TypeScript is ideal for front-end developers, full-stack engineers, and software architects who build large-scale web applications. It serves those looking to improve code excellence, reduce bugs through static checking, and maintain complex projects more.
- Lightweight, Classic fit, Double-needle sleeve and bottom hem
Describe an existing global extension
Use a global augmentation when an environment or library really provides an additional global member and your TypeScript program needs to know about it. For example, a module can declare an addition to Window:
export {};
declare global {
interface Window {
appVersion: string;
}
}
This adds a type-level description only. It does not initialize window.appVersion; the runtime code or environment must provide that property, and the declaration file must be included in the intended TypeScript program. Global augmentation, like module augmentation, is for patching existing declarations, not introducing new top-level declarations.
What merging permits—and what it rejects
Compatible properties can be contributed
When declarations of the same interface name contain the same non-function property, their types must be compatible. If one declaration says a property is a string and another gives that property an incompatible type, TypeScript reports an error rather than silently replacing the original member.
Repeated function members become overloads
Function members with the same name are treated as overloads. Their ordering matters: overloads contributed by later interface declarations take precedence over those from earlier declarations. This is useful when extending an overload set, but it means declaration order can affect which signatures are considered first.
Quick Recap
Best Value
Common mistakes to avoid
- Merging just to reuse fields: If the goal is a new, clearly named contract, use
extendsinstead of changing the meaning of a shared interface name. - Redefining a property through merging: Conflicting non-function member types are rejected; merging is not a way to overwrite a declaration.
- Assuming a declaration installs behavior: Augmentation changes what the compiler knows, not what JavaScript executes. Ensure the runtime patch or environment support is present.
- Augmenting an unavailable target: Module augmentation must resolve to an existing module declaration, cannot introduce new top-level declarations, and cannot target a default export.
- Confusing extension with implementation:
extendscomposes interface contracts. It is distinct fromimplements, and neither interface extension nor declaration merging generates runtime implementation.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

