1.2. Setting up your TypeScript development environment

TypeScript is an open-source programming language and it works on any platform (Windows, OSX and Linux). Some editors, like Visual Studio 2017, come with TypeScript pre-installed but we are going to use the TypeScript npm package throughout this book. The node package manager or npm was originally developed to manage Node.js modules and makes it easy for JavaScript developers to share, reuse and update packages. We are going to use the TypeScript npm package instead of the TypeScript plugins for the editors because by doing it we will be able to define a cross-platform workflow. This is important because we need to be able to execute the TypeScript compilation process in multiple environments and not just our development environments. In open source projects and large organizations, it is common to work in teams where each developer uses a different IDE or operating system. Defining a cross-platform workflow will help us to create a workflow that is independent of IDEs and operating systems.

Getting ready

In order to use npm we must first download and install Node.js from https://nodejs.org/en/download/.

How to do it…

  1. Once you have installed Node.js, you should be able to check if the installation was successfully by executing the following command on the console:
    $ node -v
    

    At the time of writing this book the Node.js version was v7.10.0. Please note that if you use a different version some of the contents of this book may need to be changed accordingly.

  2. If everything went well, we should be able to install the TypeScript npm package using the npm command line interface:
    $ npm install -g typescript
    
  3. Once you have installed it, you should be able to check if the installation was successfully by executing the following command on the console:
    $ tsc -v
    

    At the time of writing this book the version of the TypeScript npm package was 2.3.3. Please note that if you use a different version some of the contents of this book may need to be changed accordingly.


Shiv Kushwaha

Author/Programmer