Here is how:
Reference the Grunt-TSD Plugin:
Simply NPM install the plugin using ‘npm install grunt-tsd –save-dev’
Add reference to the plugin inside your Grunt Script:
Create a tsd.json file
In my opinion it is a bit cleaner to put your tsd configuration external to the grunt script, because of this I am following the path of creating a tds.json file. Make sure you create this file local to your gruntfile.js file. Below is my sample tsd.json file
Please note that the Path:typings entry in the tsd.json configuration is configurable. I wanted my d.ts files put into a ‘typings’ folder in my root. Of course you can change the name or location of this folder if you wish.
Download and install a Type Definition
In order to use a Type Definition you need to install it via TSD. To do this open your cmd prompt and CD into the directory which has your tsd.json file. Once there you can issue the following command ‘tsd query [package name] install -s -o’. This will install your package and update the tsd.json configuration files. For a full overview of the TSD syntax check out the TSD readme
Add the TSD task to a Registered Task
Once you have your TSD configuration node setup the last thing you will need to do is to call this from one of your Registered Tasks in your file.
Once you have all this setup you should be ready to roll. Simply issue a Grunt call to your configuration task (or use Grunt tsd) and watch the magic happen. To validate this worked as expected simply check you typings folder.
Till next time,