Tim Mouskhelichvili • January 23, 2023 • 5 minutes to read
A class is the fundamental building block of object-oriented programming languages like C# or Java. TypeScript also provides support for classes and gives developers access to such features as inheritance, encapsulation, and polymorphism. In TypeScript, a class is an [...]
Tim Mouskhelichvili • November 1, 2022 • 3 minutes to read
If you come from a C# background, you may want to add multiple constructors to a TypeScript class. Although TypeScript doesn't support multiple constructors, you can still achieve similar behavior. In TypeScript, you can achieve a similar behavior to [...]
Tim Mouskhelichvili • October 17, 2022 • 2 minutes to read
When using object-oriented programming concepts in TypeScript, often a developer needs to make a class implement an interface. Luckily, this is easy to do. To make a class implement an interface in TypeScript, you need to use the special [...]
Tim Mouskhelichvili • October 12, 2022 • 3 minutes to read
To create a read-only property in TypeScript, you need to use the readonly keyword. Here is an example of a read-only property inside an interface: interface IPerson { readonly name: string; role: string; } This article explains everything about [...]
Tim Mouskhelichvili • September 27, 2022 • 2 minutes to read
Sometimes, a TypeScript developer may need to find the class name of an object. Luckily, it is easy to do. To find the class name of an object at runtime in TypeScript, you can: Use the constructor property of [...]
Tim Mouskhelichvili • August 3, 2022 • 3 minutes to read
If you come from a computer science object-oriented programming background, you may want to utilize some of the design patterns you've always used but in TypeScript. One of the most well-known design patterns is the singleton. A singleton is [...]
Tim Mouskhelichvili • July 25, 2022 • 2 minutes to read
Sometimes, developers need to declare class constants accessible by all the class's methods. Luckily, this is very easy to accomplish in TypeScript. To declare class constants in TypeScript, you can use the readonly keyword, like so: class Cat { [...]
Tim Mouskhelichvili • July 19, 2022 • 3 minutes to read
TypeScript, just like such languages as C# or Java, provides support for abstract classes. It is a valuable feature since JavaScript doesn't support the abstract keyword. This brings the question of what is an abstract class and how it [...]
Tim Mouskhelichvili • July 11, 2022 • 3 minutes to read
TypeScript, just like JavaScript, provides support for static methods, properties, and initialization blocks. This brings the question of what a static class is and how it works in TypeScript. A static class contains static properties and methods and is [...]
Tim Mouskhelichvili • June 28, 2022 • 3 minutes to read
TypeScript is a superset of JavaScript, and just like its counterpart, it supports object-oriented principles such as class inheritance. When a class inherits another class, a developer may want to override a parent class method. Luckily, this is easy [...]