Hotrodmonkey Hotrodmonkey - 2 months ago 5
TypeScript Question

How do you produce a .d.ts "typings" definition file from an existing JavaScript library?

I'm using a lot of libraries both my own and 3rd party. I see the "typings" directory contains some for Jquery and WinRT... but how are they created?


For the most part, these are hand-created. For the things that have an external well-defined speclike the DOM (see lib.d.ts), the .d.ts file was generated using a script, but for more fluid stuff like JQuery, it's just a matter of sitting down with the documentation and typing it out. There might be automated tools to help with this in the future, but none exist yet.

If you have an existing TypeScript library that you want to generate a .d.ts file for, you can use the --declaration command-line switch:

 tsc --declaration file.ts