<commit_before>---
layout: post
title: Gulp 101 - Automatically update your TypeScript definitions in Visual Studio 2015
excerpt: "Do you use Visual Studio 2015 & Want your TypeScript definitions to automatically upgrade? Then this is the post for you."
modified: 2015-06-06
tags: [Visual Studio 2015, TypeScript, JS, Gulp, TypeScript definitions ]
comments: true
image:
  feature: sample-image-5.jpg
  credit: WeGraphics
  creditlink: http://wegraphics.net/downloads/free-ultimate-blurred-background-pack/
---
For the last six months at work, I have been writing all of my JavaScript by using TypeScript.

> For all the trials and tribulations, TypeScript has put me through I can't imagine writing JavaScript without the static typing TypeScript provides.

Due to Static typing enabling the compiler to check that operations my JavaScript performs, this feature alone has saved me from many frustrating bugs.<br><br>The very nature of JavaScript is dynamic. Therefore, for TypeScript to be able to perform static type checking, the types must be defined.  To provide this information, we must supply TypeScript with type definition files (.d.ts). <br><br>In visual studio 2015, Intellisense understands type definition files and uses them to improve autocompletion.<br><br>These definitions are extremely useful, if not required when working with  TypeScript.  Sadly with the current tooling available the creation of these useful files is very time-consuming. <br><br>Luckily, the popular DefinitelyTyped project on GitHub, which has more than 1000 contributors, together have written definitions for more than 6000 JavaScript libraries. This community also regularly improves previously written definitions. Therefore, it is important to keep the definitions in your project up to date.

Let's create a Gulp simple task which will fetch the lastest version of the definitions from the DefinitelyTyped project. [(Why did I choose Gulp over Grunt? Click here to find out why!)](http://blog.chrisbriggsy.com/Gulp-101-CSS-all-the-LESS/)

> We going to use gulp_tsd this allows us automate the process of using tsd, a tool provided by the DefinitelyTyped community, to fetch TypeScript definitions.

### 1. Add the NPM packages

* Create a new package.JSON file in the root of the project

{% gist b0501c7784065c2a3f80%}

### 2. Add the Gulp task

* Create a new gulpfile.js file in the root of the project

In this file, all of the Gulp magic happens. It contains all of the Gulp tasks for the project.
<commit_msg>tweak<commit_after>---
layout: post
title: Gulp 101 - Automatically update your TypeScript definitions in Visual Studio 2015
excerpt: "Do you use Visual Studio 2015 & Want your TypeScript definitions to automatically update? Then this is the post for you."
modified: 2015-06-06
tags: [Visual Studio 2015, TypeScript, JS, Gulp, TypeScript definitions ]
comments: true
image:
  feature: sample-image-5.jpg
  credit: WeGraphics
  creditlink: http://wegraphics.net/downloads/free-ultimate-blurred-background-pack/
---
For the last six months at work, I have been writing all of my JavaScript by using TypeScript.

> For all the trials and tribulations, TypeScript has put me through I can't imagine writing JavaScript without the static typing TypeScript provides.

Due to Static typing enabling the compiler to check that operations my JavaScript performs, this feature alone has saved me from many frustrating bugs.<br><br>The very nature of JavaScript is dynamic. Therefore, for TypeScript to be able to perform static type checking, the types must be defined.  To provide this information, we must supply TypeScript with type definition files (.d.ts). <br><br>In visual studio 2015, Intellisense understands type definition files and uses them to improve autocompletion.<br><br>These definitions are extremely useful, if not required when working with  TypeScript.  Sadly with the current tooling available the creation of these useful files is very time-consuming. <br><br>Luckily, the popular DefinitelyTyped project on GitHub, which has more than 1000 contributors, together have written definitions for more than 6000 JavaScript libraries. This community also regularly improves previously written definitions. Therefore, it is important to keep the definitions in your project up to date.

Let's create a Gulp simple task which will fetch the lastest version of the definitions from the DefinitelyTyped project. [(Why did I choose Gulp over Grunt? Click here to find out why!)](http://blog.chrisbriggsy.com/Gulp-101-CSS-all-the-LESS/)

> We going to use gulp_tsd this allows us automate the process of using tsd, a tool provided by the DefinitelyTyped community, to fetch TypeScript definitions.

### 1. Add the NPM packages

* Create a new package.JSON file in the root of the project

{% gist b0501c7784065c2a3f80%}

### 2. Add the Gulp task

* Create a new gulpfile.js file in the root of the project

In this file, all of the Gulp magic happens. It contains all of the Gulp tasks for the project.

{'fraction_non_alphanumeric': 0.05536745668193587, 'fraction_numerical': 0.022306313483369845, 'mean_word_length': 4.726339794754846, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1215618', 'n_tokens_mistral': 1354, 'n_tokens_neox': 1241, 'n_words': 702}