What is the difference between interface and abstract class?

Why Interviewers Ask This

Senior TypeScript engineers are expected to reason about architecture, performance, and edge cases. This question separates mid-level from senior candidates by testing deep system-level understanding.

Answer

Both interfaces and abstract classes define contracts, but they differ fundamentally. Interface: purely structural — describes shape only, no implementation. Cannot have constructors. A class can implement multiple interfaces. Completely erased at runtime. Can be used to describe non-class objects. Supports declaration merging. Best for defining the shape of an API without coupling to any implementation. Abstract class: can have both abstract methods (no implementation) and concrete methods (full implementation). Can have a constructor, fields, and state. A class can only extend ONE abstract class. Exists at runtime as a constructor function. Supports access modifiers on methods. Best when you want to share implementation code and enforce a contract simultaneously — the template method pattern. Choosing: use interface when you only need a contract (shape); use abstract class when you need shared behavior. Many TypeScript experts recommend favoring interfaces + composition over abstract class inheritance. Abstract classes create tighter coupling but less boilerplate for shared logic.

Common Mistake

Rushing to answer is a common mistake. Take two seconds to structure your response: definition → example → trade-off. This structure makes complex TypeScript answers easy to follow.