Book Image

Mastering TypeScript - Fourth Edition

By : Nathan Rozentals
4.5 (2)
Book Image

Mastering TypeScript - Fourth Edition

4.5 (2)
By: Nathan Rozentals

Overview of this book

TypeScript is both a language and a set of tools to generate JavaScript, designed by Anders Hejlsberg at Microsoft to help developers write enterprise-scale JavaScript. Mastering Typescript is a golden standard for budding and experienced developers. With a structured approach that will get you up and running with Typescript quickly, this book will introduce core concepts, then build on them to help you understand (and apply) the more advanced language features. You’ll learn by doing while acquiring the best programming practices along the way. This fourth edition also covers a variety of modern JavaScript and TypeScript frameworks, comparing their strengths and weaknesses. You'll explore Angular, React, Vue, RxJs, Express, NodeJS, and others. You'll get up to speed with unit and integration testing, data transformation, serverless technologies, and asynchronous programming. Next, you’ll learn how to integrate with existing JavaScript libraries, control your compiler options, and use decorators and generics. By the end of the book, you will have built a comprehensive set of web applications, having integrated them into a single cohesive website using micro front-end techniques. This book is about learning the language, understanding when to apply its features, and selecting the framework that fits your real-world project perfectly.
Table of Contents (19 chapters)
17
Other Books You May Enjoy
18
Index

What this book covers

Chapter 1, Up and Running Quickly, shows how to quickly set up a TypeScript development environment, and generate JavaScript. It also includes an introduction to the TypeScript language and its general syntax, and shows how to debug code and use 3rd party JavaScript libraries.

Chapter 2, Exploring the Type System, discusses all of the types used in the TypeScript language, and commonly used language features. It starts with primitive types and type aliases, moves on to object spread and tuples, and finally discusses the use of types in function signatures, callbacks, and overrides.

Chapter 3, Interfaces, Classes, Inheritance, and Modules, builds on the work from the previous chapter, and introduces the object-oriented concepts and capabilities of interfaces, classes, and inheritance. It then shows how to work with modules, which is how we arrange our code, but also how we consume 3rd party libraries.

Chapter 4, Generics and Advanced Type Inference, discusses the more advanced language feature of generics, before working through the concepts of advanced type inference using conditional types, type chaining, and type distribution.

Chapter 5, Asynchronous Language Features, walks the reader through asynchronous programming concepts, starting with callbacks, then on to Promises, and finally async await.

Chapter 6, Decorators, shows the reader how to build and use decorators, which are used within some of the popular Single-Page Application frameworks.

Chapter 7, Integration with JavaScript, takes a look at declaration files, how to find them, how to use them, and how to write them. It also discusses the various compiler options that assist with integrating JavaScript and TypeScript files within the same project.

Chapter 8, Strict Compiler Options, works through each of the strict set of compiler options available with the TypeScript compiler, and explains what errors these options will automatically pick up within our code.

Chapter 9, Using Observables to Transform Data, discusses the RxJS library, and how it uses the Observable pattern to handle streams of events. It discusses how to register for an event stream, how to process data as it flows through the stream, and how to transform this data and create new streams, using combinations of operators.

Chapter 10, Test-Driven Development, explores the Jest unit testing framework, and how to write tests to cover a multitude of test cases. It also discusses asynchronous testing techniques, tests that update the DOM, and how to run end-to-end tests against a running website.

Chapter 11, Angular, discusses the Angular SPA framework, including shared modules, Angular services and form-based input. It builds a website using Angular that combines all of these techniques, along with the Angular Material set of components.

Chapter 12, React, walks through setting up and building a React website using TypeScript and the JSX syntax. It discusses props, event handling, state, and how to use React forms, along with integration of the Material UI library for React.

Chapter 13, Vue, sets up and builds a Vue web-site using TypeScript and class syntax. It walks through Vue components, child components, props, and state, as well as computed properties and form handling, integrating with the Bootstrap Material UI library.

Chapter 14, Node and Express, builds an Express web server with a few lines of code running in Node. It then expands on this to build a functional multi-page Express application, including page redirects, form processing, and session variables.

Chapter 15, An AWS Serverless API, shows how to use Amazon Web Services libraries to build and deploy a full REST-based API using Serverless technologies, backed by a DynamoDB database.

Chapter 16, Micro Front-Ends, discusses the concepts around micro front-ends, and how multiple front-ends can communicate with each other. It then goes on to combine the web sites built within the book using Angular, React, and Vue into a single application using these micro front-end techniques, integrating the REST API built using AWS.