5 Using the TypeScript compiler
This chapter covers
- Installing the TypeScript package using the Node Package Manager
- Creating a configuration file for the TypeScript compiler
- Using the TypeScript compiler to generate Java Script code
- Choosing the version of the JavaScript lan guage targeted by the TypeScript compiler
- Selecting the JavaScript module format used by the TypeScript compiler
In this chapter, I show you how to use the TypeScript compiler, which is responsible for transforming TypeScript code into JavaScript that can be executed by browsers or the Node.js runtime. I also describe the compiler configuration options that are most useful for TypeScript development, including those that are used with the web application frameworks covered in part 3 of this book.
5.1 Preparing for this chapter
To prepare for this chapter, open a command prompt, navigate to a convenient location, and create a folder named tools. Run the commands shown in listing 5.1 to navigate to the tools folder and to tell the Node Package Manager (NPM) to create a file named package.json. This file will be used to keep track of the packages added to the project, as described in the “Using the Node Package Manager” section.
Listing 5.1 Creating the package.json file
cd tools npm init --yes
Use the command prompt to run the commands shown in listing 5.2 in the tools folder to install the package required for this chapter.