{
  "id": 22374472,
  "title": "TypeScript: Do you know the differences between type and interface?",
  "url": "https://urgent.news/2026/11/28/typescript-do-you-know-the-differences-between-type-and-interface",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-28T13:46:07.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/ravianand1988/typescript-do-you-know-the-differences-between-type-and-interface-1ia0"
  },
  "original_language": null,
  "account": "TypeScript offers two primary ways to define object shapes: type and interface . While they appear similar, there are key differences to consider when choosing one over the other.\n\nBoth type and interface describe an object with the same properties. For instance:\ntype Person = { name : string ; age : number ; }\ninterface Person { name : string ; age : number ; }\n\nHowever, one notable difference arises when introducing extra properties. With both type and interface, TypeScript raises an error for excess properties, known as an excess property check. This is a crucial distinction between the two.\n\nInterestingly, interfaces can extend other interfaces, whereas type aliases cannot. For example:\ninterface Employee extends Person { salary : number ; }\n\nLikewise, an interface can be extended by a type using intersection types:\ninterface Person { name : string ; age : number ; }\ntype Employee = Person & { salary : number ; }\n\nAnother point of differentiation is the ability to union types with type aliases. Type aliases can combine unions and intersections, offering greater flexibility. For instance:\ntype StringOrNumber = string | number;\ntype InputOrOutput = ( Input | Output ) & { name : string ; }\n\nIn contrast, interfaces lack union type syntax. Attempting to extend an interface with a union type results in an error.\n\nDeclaration merging is another area where interfaces shine. Unlike type aliases, interfaces can be merged together seamlessly. Consider this scenario:\ninterface Person { name : string ; age : number ; }\ninterface Person { city : string ; }\n\nThe TypeScript compiler merges both declarations into a single interface, allowing access to all properties defined. This declaration merging capability proves useful for extending third-party library declarations, augmenting global interfaces, or creating extensible public APIs. However, it's essential to use declaration merging judiciously to avoid unintended consequences.\n\nSo, which should you choose? Type or interface? Ultimately, the decision depends on your specific needs and project requirements. Consistency within your codebase is key. If your existing project primarily uses interfaces, it makes sense to stick with that convention. Conversely, if you frequently need unions, intersections, or declaration merging, type aliases might be a better fit.\n\nFor new projects, consider whether declaration merging is a requirement. If so, interface might be the ideal choice, particularly when defining object contracts that allow library consumers to augment your public declarations. On the other hand, if you primarily need unions, intersections, or more advanced type compositions, type aliases are likely the better option.\n\nUltimately, both type and interface serve as powerful tools for describing types in TypeScript. Your choice should be guided by the unique demands of your project and the desired level of flexibility and extensibility in your type definitions.",
  "summary": "They look almost identical, but there are some important differences. Let's explore when to use each. When defining the shape of an object in TypeScript, we generally have two options: type and interface . Let's start with a simple example: type Person = { name : string ; age : number ; } ; // Using an interface interface Person { name : string ; age : number ; } Both approaches describe an…",
  "summary_source": "publisher",
  "key_points": [
    "Type and interface both describe object shapes with same properties",
    "Interfaces can extend other interfaces, type aliases cannot",
    "Interfaces support declaration merging, type aliases do not"
  ],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}