Classes and Type Annotations
There are many references for ES6 classes and we can find the basic syntax here.
The goal of the TypeScript extensions to class syntax is to allow the TypeScript compiler to treat object attribute references and method calls the way that functions and assignments are treated. We want to be able to tell from the class of the instance what attributes exist and the expected type of those attributes.
In TypeScript, any method defined in a class is available to instances of the class. We can annotate arguments and return the values of a method just as we would for functions.
this.color = "red", the existence of the
color attribute needs to have already been declared.
Again, we’ve already seen this at the beginning of our