How are you dealing with inaccurate and outdated declaration files?

Topics: General
Dec 10, 2012 at 4:56 PM
Edited Dec 10, 2012 at 5:45 PM

One of TypeScript's limiting factors seems to be its dependency on declaration files for popular frameworks such as jQuery, Bootstrap, D3, etc.

I usually use DefinitelyTyped to locate my *.d.ts files, but I find they are often rapidly out-of-date with the latest release , inaccurate, and/or incomplete.

The fact these need to be built by hand seems to be the issue. And it doesn't seem like many framework authors are investing the time in building them.

I feel like TypeScript needs to automate building these files, or better yet, figure out a way to remove the dependency altogether. It would sweet if we could just reference .js files directly, and TypeScript dynamically builds the best declarations it can, and if it can't figure something out, then just "any" it.

Thoughts?

 

Coordinator
Dec 11, 2012 at 5:46 PM

The tension with having to maintain .d.ts files shows up a few places.  Like you mention, it's up to the user to keep them up to date when using third-party .js libraries.  It also comes up if you set up your project into subprojects and use the .d.ts files as the interface of each submodule.  You'd have to make sure the .d.ts files stay up to date.

The former, though, doesn't have a clean solution, at least not yet.  We don't have a way yet of creating .d.ts from .js files, though there is some work going on now to make that easier (https://npmjs.org/package/jsdocts for example).  Likewise, if .js files pointed to the corresponding .d.ts files in a standard way, we could potentially support that.

We can help with the latter by helping the user generate the .d.ts files as part of the compilation using the --declaration commandline option.