Question · JavaScript and TypeScript course · Module 7: Advanced TypeScript

Declaration Merging

What happens when you declare two interfaces with the same name in TypeScript?

Answer options

  • TypeScript will report a compilation error - duplicate name
  • The second interface will overwrite the first
  • TypeScript will merge both interfaces into one (declaration merging)
  • Only the first interface will be visible, the second will be ignored

You can check the correct answer by solving this task in the CodeWorlds game.