Book Image

Advanced TypeScript Programming Projects

By : Peter O'Hanlon
Book Image

Advanced TypeScript Programming Projects

By: Peter O'Hanlon

Overview of this book

With the demand for ever more complex websites, the need to write robust, standard-compliant JavaScript has never been greater. TypeScript is modern JavaScript with the support of a first-class type system, which makes it simpler to write complex web systems. With this book, you’ll explore core concepts and learn by building a series of websites and TypeScript apps. You’ll start with an introduction to TypeScript features that are often overlooked in other books, before moving on to creating a simple markdown parser. You’ll then explore React and get up to speed with creating a client-side contacts manager. Next, the book will help you discover the Angular framework and use the MEAN stack to create a photo gallery. Later sections will assist you in creating a GraphQL Angular Todo app and then writing a Socket.IO chatroom. The book will also lead you through developing your final Angular project which is a mapping app. As you progress, you’ll gain insights into React with Docker and microservices. You’ll even focus on how to build an image classification program with machine learning using TensorFlow. Finally, you’ll learn to combine TypeScript and C# to create an ASP.NET Core-based music library app. By the end of this book, you’ll be able to confidently use TypeScript 3.0 and different JavaScript frameworks to build high-quality apps.
Table of Contents (13 chapters)

Preface

This is a book about TypeScript; but then again, you got that from the title. But it's more than just a book about TypeScript. This is a book about how TypeScript can be used to go beyond basic examples. That means that this is a book about topics that are just that little bit harder than you might already have covered in your first forays into the world of TypeScript.

So, we could probably rephrase that opening sentence to "This is a book about TypeScript and some of the fun and cool ways that you can use TypeScript with technologies that are more advanced than ones I've been using before".

Upfront, I will say that this book is not a book about how to program in Angular, React, Vue, or ASP.NET Core. Those are big topics that deserve their own separate books (indeed, at the end of each chapter, I do my best to point you toward other resources that will help you learn these technologies on a much deeper level than the brief chapters we will have on them). Instead, for Angular and React, I try to limit the introduction of new features to no more than five new concepts per chapter. Where we are using a technology such as Bootstrap, which has a technology-specific implementation, we will use the library that is most appropriate, such as reactstrap for React. We do this because these libraries have been designed to work with the user interface (UI) framework in question.

When we were doing the initial research for this book, one of the questions that kept cropping up was, "what's hot right now? What are people using that's new and exciting?" This book aims to offer an introduction to some of those technologies, including GraphQL, microservices, and machine learning. Again, this book cannot teach everything about the relevant technology. What it does do is provide an introduction to the technology and show how we can leverage the power of TypeScript to make our lives so much easier when developing with it.

One thing we will find as we go through the book is that I tend to focus on object-oriented programming (OOP) pretty heavily. We will be building a lot of classes. There are many reasons for this, but the biggest reason for this focus is that in early chapters, we are going to be writing code that we can make use of in later chapters. I also wanted to write code that you could just drop into your own code base if you wanted to. With TypeScript, class-based development makes this make this so much simpler. This also gives us the opportunity to talk about techniques that we can apply to make code simpler, even when using more advanced technologies, so we cover principles such as classes having a single responsibility (known as the Single Responsibility Pattern), and pattern-based development, where we apply well-known software engineering patterns to complex problems to make the solution simple.

As well as TypeScript, we are going to be looking at using Bootstrap for the UI for most of the chapters. In the couple of chapters on Angular, we do look at using Angular Material instead of Bootstrap for laying out interfaces, because Material and Angular go hand in hand, and if you end up developing commercial Angular applications, then chances are that you are going to use Material.

The first chapter introduces us to features that we might not have used before, such as rest and spread, so we will cover them in more depth there. In later chapters, we will be using these features in a way that should become natural, so, rather than disturbing the flow of the code by calling out a particular item, we will tend to just use the features in a way that becomes second nature. The other side to this is that, as we progress through the book, we will find that features from earlier chapters will generally be touched on again, so that we don't just do something once and then forget about it.