Using Typecript Typing in Visual Studio 2015

Today I learned something new with Typescript.
When I started with Typescript we used the .d.ts files from typescript.

It was cumbersome because it required always copying those files.

Well the Typescript community has been busy and now we have TypeScript Typings https://github.com/typings/typings

However it was not very clear to me how to use it. In reality it is very simple.

Follow these steps
1. Install Typescript using nuget Microsoft.TypeScript.MSBuild. I prefer this approach because it work well on build machines.
2. Add a tsconfig.json. This is a configuration file for typescript file
3. Add a package.json file. This is configuration file for Node JS NPM Tool
4. Add a pre-build event to execute npm install

Ok so now you are almost ready.

To install your typings you should go to the command line.
Let's say you want to use kendo-ui typings.

go to the command line and execute:

npm install --save-dev @types/kendo-ui  

To use the types on your project do something like:

import '@types/kendo-ui';

class Class1  
{
    x: kendo.ui.Alert;
}

The TS CONFIG should be something like:

{
  "compilerOptions": {
    "lib": [ "es2015", "es2015.iterable", "dom" ],
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5",
    "outDir": "salida"
  },
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}

The outDir property sets the output directory.

The lib setting is important for jquery typings compilation.