TypeScript - Advanced classes

Classes in JavaScript, and consequently in TypeScript, continue to receive new features with each ES version. Some unique and exotic features can be applied to further enhance the typing system in this part of the codebase.

This is magic

I know that the this argument for methods of classes receives special treatment during the compilation process

I also understand that I do not need to explicitly define it when a method is declared inside a class

This typeguard pattern

I know that I can create a type guard that will handle code for a specific type of inherited class

Public, private and protected

I know that TypeScript allows marking parameters and methods as public, private, and protected, but this is only enforced at the type checking level

I also know that I can still use the # prefix

Instance of vs constructor signature

I know how to handle when function needs an instance of specific class as and argument

I know how to declare properly that function accepts a class constructor

Icon of TypeScript
Icon of Advanced classes
TypeScript skill
optional
Advanced classes
Ready to learn
Required technologies

I know that the this argument for methods of classes receives special treatment during the compilation process

I also understand that I do not need to explicitly define it when a method is declared inside a class

I know that I can create a type guard that will handle code for a specific type of inherited class

I know that TypeScript allows marking parameters and methods as public, private, and protected, but this is only enforced at the type checking level

I also know that I can still use the # prefix

I know how to handle when function needs an instance of specific class as and argument

I know how to declare properly that function accepts a class constructor

Close
Loading content