Book Image

Learning TypeScript 2.x - Second Edition

By : Remo H. Jansen
Book Image

Learning TypeScript 2.x - Second Edition

By: Remo H. Jansen

Overview of this book

TypeScript is an open source and cross-platform statically typed superset of JavaScript that compiles to plain JavaScript and runs in any browser or host. This book is a step-by-step guide that will take you through the use and benefits of TypeScript with the help of practical examples. You will start off by understanding the basics as well as the new features of TypeScript 2.x. Then, you will learn how to work with functions and asynchronous programming APIs. You will continue by learning how to resolve runtime issues and how to implement TypeScript applications using the Object-oriented programming (OOP) and functional programming (FP) paradigms. Later, you will automate your development workflow with the help of tools such as Webpack. Towards the end of this book, you will delve into some real-world scenarios by implementing some full-stack TypeScript applications with Node.js, React and Angular as well as how to optimize and test them. Finally, you will be introduced to the internal APIs of the TypeScript compiler, and you will learn how to create custom code analysis tools.
Table of Contents (17 chapters)

Preface

Over the past decade, the JavaScript code base of an average web application has been growing exponentially. However, the current version of JavaScript was designed several years ago and lacks some features necessary to cope with the level of complexity that we may find in a modern JavaScript application. Owing to these missing features, maintainability problems have arisen.

The ECMAScript 2015 specification is meant to solve some of the maintainability issues of JavaScript, but its implementation is in progress, and many incompatible web browsers are still in use today. For these reasons, wide adoption of the ECMAScript 2015 specification is expected to be a slow process.

To resolve the maintainability and scalability problems of JavaScript, TypeScript was publicly announced in October 2012, after 2 years of internal development at Microsoft:

"We designed TypeScript to meet the needs of the JavaScript programming teams that build and maintain large JavaScript programs. TypeScript helps programming teams to define interfaces between software components and to gain insight into the behavior of existing JavaScript libraries. TypeScript also enables teams to reduce naming conflicts by organizing their code into dynamically loadable modules. TypeScript’s optional type system enables JavaScript programmers to use highly-productive development tools and practices: static checking, symbol-based navigation, statement completion, and code refactoring."
—TypeScript Language Specification 1.0

Some developers with many years, experience in web development will find it challenging to define a large-scale JavaScript application. When referring to this term, we will avoid considering the number of lines of code in the application. It is much better to consider the number of modules and entities in an application, and the number of dependencies between them as units of measurement of the application’s scale. We will define large-scale applications as nontrivial applications that require significant developer effort to be maintained.

Learning TypeScript 2.x Second Edition, introduces many of the TypeScript features in a simple and easy-to-understand format. This book will teach you everything you need to know to implement a large-scale JavaScript application using TypeScript. Not only does it teach TypeScript’s core features, which are essential to implement a web application, but it also explores some powerful development tools, design principles, and good practices, and demonstrates how to apply them to real-life applications.

The second edition has been upgraded and extended, with five additional chapters that cover topics such as functional programming, advanced type system features, an introduction to frontend development with React and Angular, an introduction to Node.js development, and an introduction to the internal APIs of the TypeScript compiler.

The new edition contains a total of 15 chapters. Seven of these chapters are completely new and were not included in the first edition.