| Start |
|---|
Abstract Classes Abstract classes are base classes from which other classes can extend. They cannot be instantiated themselves (i.e. you cannot do The two key characteristics of an abstract class in Typescript are:
For this reason, abstract classes can conceptually be considered a combination of an interface and a class. |
Simple class In this example, we declare a simple class |
Basic Inheritance This examples shows how to create a very simple subclass of the |
| Constructors In this example we use the One of the best things in TypeScript, is automatic assignment of constructor parameters to the relevant property. All this code can be resumed in one single constructor: And both of them will be transpiled from TypeScript (design time and compile time) to JavaScript with same result, but writing significantly less code: Constructors of derived classes have to call the base class constructor with |
| Accessors In this example, we modify the "Simple class" example to allow access to the |
| Monkey patch a function into an existing class Sometimes it's useful to be able to extend a class with new functions. For example let's suppose that a string should be converted to a camel case string. So we need to tell TypeScript, that Now we can patch this function into the If this extension of |
| Transpilation Given a class TypeScript sourceJavaScript sourceWhen transpiled using TypeScript Observations
|
Read Article
https://develop.horje.com/learn/1434/reference