1. Home
  2. Training Library
  3. Programming
  4. Courses
  5. An Introduction to Typescript

How to install the TypeScript Toolset

Developed with



The course is part of this learning path

Typescript: Zero to Hero
How to install the TypeScript Toolset


We begin with an introduction to what Typescript is.

Learning Objectives

The objectives of this module are to provide you with and understanding of:

  • What TypeScript is
  • Know how to install the TypeScript Toolset

Intended Audience

This learning path is aimed at all who wish to learn how to use TypeScript


It is essential you understand the face of contemporary web development to attend this course. You should have a good working knowledge of Javascript. Please note: Before attending this class delegates must have a Microsoft account (signing up for one is free). 


We welcome all feedback and suggestions - please contact us at qa.elearningadmin@qa.com to let us know what you think.


Scaled application development using any form of JavaScript uses a common toolset with particular additions depending on the application being built. And a TypeScript application is no different. You'll need npm installed, meaning no JS installed to manage your dependencies, the TypeScript compiler to convert your TypeScript files to a JavaScript and some form of module bundle will also be needed. The most common module bundler is webpack. This will take all of your compiled JavaScript and create a single bundle distributable JavaScript file, and it can be set up to bundle HTML and CSS too. You can also set it up to provide a live development server to hot load as you develop. Installing TypeScript is done through npm. Using the command npm install -g for global TypeScript will install everything you need. This gives you access to the TypeScript compiler anywhere on your system. Then using the command tsc and the TypeScript file name, will make the compiler produce the equivalent JavaScript file and show you any errors it comes across. This is a quick way to get up and running. But if we start to produce modules, it suddenly becomes unwieldy and unscalable. We're going to be as lightweight as possible for the course as we are trying to focus on learning TypeScript. But we are gonna show you how to set up webpack so you can use a development server and have files hot loaded. Webpack is almost zero configuration. We just need to tell it how to find and deal with the TypeScript files. We've set up an npm project using the npm in it -y command, and we've got TypeScript in the TypeScript loader for webpack installed as development dependencies. There's also webpack webpack-cli and webpack-dev-server installed as development dependencies. Running the npm in it -y command accepts all the defaults for project and creates a package.json file. You can see the development dependencies on line 16 to 20. And we've modified the script section so it returns line seven to 10. These allows the bundler files for production, or as a development bundle, which is useful for testing. Start allows us to hot load the app in the browser using the devServer and this is useful if the TypeScript will be attached to a web application. The check TypeScript compiles all the TypeScript modules by pointing to the TypeScript compiler. To configure webpack, we've created a webpack config JavaScript file as shown now, which points to a file called index.ts in a folder called src. It looks for files with the extensions ts or js, meaning we don't need to include these in the imports if we use them. The module real section checks to see if a file extension that begins with ts has been found. And we'll apply the ts loader module to them. This is what finds bundles and compiles our TypeScript files into the main bundle. We have some control over TypeScript and we can exercise this in the ts config JSON file. In this instance, we instruct the compiler to produce es5 standard JavaScript rather than the default es3 standard. We need an src folder in our project. So this has been created. And we've put a file in there called index tx. And it's got some simple code in there. To view the file running in the browser, we need a web page. So there's an index.html tag, that has a script that attaches the main.js file. That's the file webpack will bundle for us. If we look at the script commands, we can run the build command. This will produce the production-ready version of JavaScript. It produces a folder called dist, and if we open the main.js file, you can see that it's created minimize JavaScript. If we now run the npm dev command, you can see that this bundle file is replaced with one that is not minimized. And that makes it good for testing. Running the check types command, files up the TypeScript compiler and produces the outputted JavaScript. If we use the npm run start command, this spins up the webpack-dev-server, compiles and bundles the TypeScript file to main JS, which is held dynamically on the server rather than on disk and runs it all. And if we go to the dev tools, we can see that we've logged our hello world out to the console. So that's how we set up a scalable environment. If you wanna do anything more complicated like add additional polyfills Phyllis, there are plenty start repo, pause out there on the internet and other instructions to for installing PayPal

About the Author
Learning paths6

An outstanding trainer in software development with more than 15 years experience as a Corporate and Apprentice Trainer, ICT Teacher and Head of Department, with a passion for technology and its uses. Continuing to develop existing and new skills and courses, primarily in web design using PHP, JavaScript, HTML, CSS and SQL but also OOP (Java), programming foundations (Using Python), DevOps (Git, CI/CD, etc) and Agile/Scrum. Practically minded, a quick learner and a problem solver with an attention to detail to ensure high quality outcomes.

Covered Topics