Setting Up a Basic Typescript Environment

In this blog post we are going to cover a basic setup for working with Typescript and Typings in a Node environment. This is the starting point of many other post on this blog.

Setting Up the Environment

The first step in the process is to create a working directory. We are going to use the generic name project-name but feel free to use a more meaningful name for your own project.

The next step is to create a package.json file and install our main dependencies, Typescript and Typings.

We can now add our own commands to package.json to work with the local version of the libraries just installed.

We also need to create the file tsconfig.json to instruct typescript how to compile our files using one of our custom commands.

Finally, because we are going to be using the latest javascript features in our code, we need to install the typescript definitions for ES6.

We are ready now to start creating typescript files. To compile our typescript files on the fly, we can use one of our custom commands.

Now, every time a new typescript file is created or updated, the compiler will do its work and create the corresponding javascript file automatically.

The source code for this setup can be found here.

Published by

David Barreto

David Barreto is a Javascript Developer with a Bachelor's degree in Electronics Engineer and a Master's degree in Systems Engineering. He is passionate about developing web apps, teaching programming, discovering new technologies and learning all about software development methodologies. He currently works at Rangle.io in Toronto.

One thought on “Setting Up a Basic Typescript Environment”

Leave a Reply