Interfaces vs Abstract Classes

Summary: in this tutorial, you’ll learn about the differences between interfaces and abstract classes.

Interfaces and abstract classes are both powerful tools in TypeScript for designing and organizing your code, but they serve slightly different purposes.

The following table illustrates the differences between interfaces and abstract classes:

AspectInterfacesAbstract Classes
PurposeDefine contractual structure.Provide common functionality and structure.
ImplementationContains only method signatures.Can contain implemented methods and abstract methods.
Multiple InheritanceSupports multiple interface implementation.Supports single class inheritance.
Implementation FlexibilityNo implementation code in interfaces.Mixes implemented and abstract methods.
ExtensibilityEasily extendable by adding new properties/methods.Can provide shared methods for derived classes.
ConstructorsNo constructors in interfaces.Can have constructors for initialization.
Type CheckingEnsures objects adhere to the structure.Provides a common type and functionality.
InstantiationInterfaces can’t be instantiated.Abstract classes can’t be instantiated directly.
UsageDesigning contracts and structure.Sharing functionality among related classes.
Was this tutorial helpful ?