TypeScript - Classes
Working with classes in JavaScript used to be quite challenging until the class
keyword was introduced in the ES6 specification. TypeScript further enhances the experience with this controversial part of JavaScript and provides safer code handling.
Classes work effectively with interfaces, allowing developers with experience in other object-oriented programming (OOP) languages to find familiar and for basic patterns.
Basic class
I can create a basic class with TypeScript support for specifying the types of its methods and properties
Implementing interface
I can create an interface and use it to enforce its implementation in newly created classes
Constructor
I know how to define constructor types inside an interface and how to define their overloads
Inheritance and super methods
I know that I can extend existing classes and even override the types of their existing methods and properties
I also understand how the super argument works
I can create a basic class with TypeScript support for specifying the types of its methods and properties
I can create an interface and use it to enforce its implementation in newly created classes
I know how to define constructor types inside an interface and how to define their overloads
I know that I can extend existing classes and even override the types of their existing methods and properties
I also understand how the super argument works