Consumes es2015-publish-template project using npm via github registry and lodash via npm
##Running this example Make sure you have typings installed globally first
npm install typings -g
npm install
typings install
node app.js
- npm
- github registry
- npm registry
- typings
- lodash
The key takeaway with this example is we are able to display intellisense module "d.ts" declaration files within our IDE. For lodash, we can rely on the public "typings" registry. Simple enough right? What about our own library project?
Stepping out of this example project, let's pretend we're about to publish our library for the world to consume. We'd like to generate a d.ts definition file for coding ease. Here are some popular options:
- upload to DefinitelyTyped for eventual consumption via command "tsd"
- upload to the typings registry for eventual consumption via command "typings"
- keep it within our source, exposed within package.json's "typings" property
It turns out, option 1 is deprecated as mentioned here. Option 2 might be nice if we had a large, heavily relied upon public codebase and we were willing to undergo submission collaboration. This example actually relies on option 2 for loading lodash definitions. Option 3 looks most reasonable for our small library.
Option 3 is pretty simple too. It's just one step. From library project to be published, point package.json "typings" property to your generated index.d.ts
{
"typings": "dist/es2015/index.d.ts"
}
That's it! Packages deployed with the "typings" property will enable the IDE to provide helpful intellisense.