Classes, enums and modules

This part turns to classes with fields, constructors and parameter properties, public, private and protected, interfaces as contracts, abstract classes, static members and accessors. The part ends with enums, ES modules and the decorators a class can carry.

4.1 Classes fields and methods, the this of a method, and instances made with new Open 4.2 Constructors a constructor method, parameter properties, and strict property initialisation Open 4.3 Modifiers public, private and protected members, and readonly fields Open 4.4 implements an interface as a contract, a class that implements several, and refactors the compiler checks Open 4.5 Abstract classes an abstract skeleton, abstract methods a subclass must write, and how it differs from an interface Open 4.6 static static fields shared by every instance, static factories, and this inside a static method Open 4.7 Getters and setters get and set, a setter that validates, backing fields, and when a plain field is better Open 4.8 Enums numeric, string and const enums, and the literal union that often replaces one Open 4.9 ES modules export and import, a default export, and the import extension the compiler wants Open 4.10 Decorators what a decorator is, class and method decorators, and the standard they now follow Open

Lessons