October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

When to Use Declaration Merging Instead of Extending a TypeScript Interface

Use interface extension for a new derived contract; use declaration merging to intentionally add members to an existing interface name, especially through module or global augmentation.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use extends to define a new interface that reuses members from one or more base interfaces. Use declaration merging when separate declarations with the same interface name are intentionally meant to contribute to one combined type—especially when you need to augment a library or global interface you cannot edit. Merging changes what TypeScript knows; it does not add JavaScript behavior.

Extension and merging solve different problems

With extension, you create a distinct interface and state its relationship to existing interfaces:

interface Identified {
  id: string;
}

interface User extends Identified {
  displayName: string;
}

User is a new name whose members include those of Identified plus displayName. An interface can extend more than one interface. Choose this when you own the API shape and want a clear derived contract. See the TypeScript Handbook’s object types and interface documentation.

Declaration merging works by name: separate declarations of the same interface are combined into one definition. As the TypeScript Handbook explains, merging means the compiler combines separate declarations declared with the same name. This is useful when the intended result is to add members to an existing named interface, rather than define a separate derived interface.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the mechanism that matches the target

Situation Use Why
You control a new API shape and want it to reuse one or more base interfaces. Extension A separately named interface makes the relationship explicit without changing the original interface for every consumer.
A third-party module provides a runtime capability, but its existing named export lacks the corresponding type declaration. Module augmentation Augment the existing exported interface so its type describes the capability; the runtime patch must also be supplied and loaded.
A runtime environment provides a global capability that needs type support. Global augmentation Declare the added members on the existing global interface, provided the runtime really supplies them.
You are composing or specializing a type in code you control. Usually extension A distinct name avoids silently changing the shape associated with a shared interface name.

Use augmentation to describe an existing runtime extension

For a module augmentation, target the actual module specifier and named export used by the package. The Handbook’s example augments a named Observable<T> export to describe a map method. The declaration describes the existing export; it does not implement the method.

If the runtime library adds the method by patching a prototype, that code must exist independently and be loaded where needed. The Handbook’s example separately assigns Observable.prototype.map and augments the type declaration. Without the runtime implementation, TypeScript may accept a call that fails when executed.

Rank #2
TypeScript Programming Language - Software Engineer & Coder T-Shirt
  • 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

For a global extension, place an augmentation inside a module, for example:

export {};

declare global {
  interface Window {
    appFeature: string;
  }
}

Include the declaration file in the TypeScript program, and add the field only if the application or environment actually initializes it. A type declaration is not a runtime initializer.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Know the limits of same-name declarations

Conflicting properties are errors

When declarations merge, duplicate non-function members must be compatible. Declaring the same property with incompatible types is rejected by the compiler; merging is not a way to override a property’s type.

Function overload order matters

Repeated function members contribute overloads. Overloads from later interface declarations take precedence over those from earlier declarations in the merged overload list, so declaration order can affect overload resolution.

Augmentation patches existing declarations only

Module augmentation targets a module TypeScript can resolve through ordinary module-specifier resolution. It can add to existing declarations, but cannot introduce new top-level declarations, and it cannot augment a default export. Global augmentation has the same patch-only boundary: it extends an existing global declaration rather than creating a new unrelated declaration.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Do not confuse extension with implementation

extends describes a type relationship between interfaces; implements checks whether a class satisfies an interface contract. Neither declaration mechanism generates JavaScript implementation. Use extension for a new related interface, merging for intentional contributions to an existing interface name, and separate runtime code whenever the added capability must actually run.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.