2 Your first TypeScript application

 

This chapter covers

  • Preparing the tools required for TypeScript development
  • Creating and configuring a TypeScript project
  • Using the TypeScript compiler to generate pure JavaScript code
  • Executing pure JavaScript code using the Node.js runtime
  • Preparing a TypeScript project for use with ECMAScript modules
  • Installing and using a third-party JavaScript package
  • Using type declarations for a third-party JavaScript package

The best way to get started with TypeScript is to dive in. In this chapter, I take you through a simple development process to create an application that keeps track of to-do items. Later chapters show how TypeScript features work in detail, but a simple example will be enough to demonstrate how the basic TypeScript features work. Don’t worry if you don’t understand everything in this chapter. The idea is just to get an overall sense of how TypeScript works and how it fits into an application.

2.1 Getting ready for this book

Four packages are required to get ready for this book. Perform each installation described in the following sections and run the test provided for each of them to ensure that the packages work as they should.

2.1.1 Step 1: Install Node.js

2.1.2 Step 2: Install Git

2.1.3 Step 3: Install TypeScript

2.1.4 Step 4: Install a programmer’s editor

2.2 Creating the project

2.2.1 Initializing the project

2.2.2 Creating the compiler configuration file

2.2.3 Adding a TypeScript code file

2.2.4 Compiling and executing the code

2.2.5 Defining the data model

2.2.6 Adding features to the collection class

2.3 Using a third-party package

2.3.1 Preparing for the third-party package

2.3.2 Installing and using the third-party package

2.3.3 Adding type declarations for the JavaScript package

2.4 Adding commands

2.4.1 Filtering items

2.4.2 Adding tasks

2.4.3 Marking tasks complete

2.5 Persistently storing data

Summary