02 / 05

How to reopen Interface?

"Reopening the interface" in TypeScript refers to the ability to declare an interface with the same name multiple times, with TypeScript automatically merging all declarations into a single, combined interface. This feature is formally known as declaration merging.

  1. 1

    To reopen an interface, declare a new interface with the same name as the existing interface and add the new properties.

  2. 2

    The TypeScript compiler will merge the two interfaces, resulting in a single interface with all of the properties from both declarations.

For example, the following code shows how to reopen an interface to add a new property:
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.