Member-only story

TypeScript Interfaces & Abstract Classes. When to use which.

Badih Barakat
12 min readMay 9, 2023

--

Photo by UX Indonesia on Unsplash

I’ve written an article before about abstract classes and interfaces in PHP, “PHP Interfaces & Abstract Classes. When to use which.” explaining what each one is and when to use each one in PHP Object-Oriented Programming. As the tendency is more now a days towards JavaScript and in particular, towards TypeScript, I felt that I should write another article to show and explain the same features in TypeScript due to the importance of abstract classes and interfaces in TypeScript to emphasize on the OOP nature of this superset language of JavaScript. So, let’s get started 🙂.

Like most of the OOP languages, TypeScript offers quite a range of OOP features to impower your logic and problem solving abilities. Two of these features which are quite useful are Interfaces and Abstract Classes. Actually, according to my experience, interfaces are so frequently used.

And, when looked at, they may both sound the same at first. Both have methods signatures with no implementations, and both are used in the definition of other classes. But, again, that’s not the full picture!

Let’s look at each one of them and it’s features, first. Get to know each one better and then decide which one is good for what.

TypeScript Interfaces

--

--

Badih Barakat
Badih Barakat

Written by Badih Barakat

A Software Developer with 15 years of experience on various platforms.

Responses (3)