Appendix B. TypeScript essentials


TypeScript was released in 2012 by Microsoft, and its core developer was Anders Hejlsberg. He’s also one of the authors of Turbo Pascal and Delphi, and is a lead architect of C#. In this appendix, we’ll cover main elements of the TypeScript syntax.

We’ll also show you how to turn TypeScript code into JavaScript (ES5) so it can be executed by any web browser or a standalone JavaScript engine. This appendix doesn’t offer a complete coverage of TypeScript. Refer to the TypeScript documentation at for complete coverage. Also, TypeScript supports all syntax constructs described in appendix A, so we don’t repeat those here.

B.1. The role of transpilers

Web browsers don’t understand any language but JavaScript. If the source code is written in TypeScript, it has to be transpiled into JavaScript before you can run it in a JavaScript engine, whether browser or standalone.

Transpiling means converting the source code of a program in one language into source code in another language. Many developers prefer to use the word compiling, so phrases like “TypeScript compiler” and “compile TypeScript into JavaScript” are also valid.

B.2. Getting started with TypeScript

B.3. How to run the code samples

B.4. Optional types

B.5. Functions

B.6. Classes

B.7. Interfaces

B.8. Generics

B.9. The readonly modifier

B.10. Decorators

B.11. The union type

B.12. Using type definition files

B.13. Controlling code style with TSLint