moefinley
moefinley

Reputation: 1329

How to manage your own TypeScript declaration files across projects

I have an assets/CDN project which contains my own and third party libs like JQuery. My own scripts are written in TypeScript. All these files get referenced in about five different projects.

If I want to write some TypeScript in one of those five projects that references some TypeScript in the assets project I manually generate and copy across a declaration file.

What would be your recommendation for a better way to manage this process?

I'm using Grunt to run the TypeScript compiler. I can run it with the 'declarations' option but this won't let me put all the declarations in a separate folder ready to be 'collected' by the other projects.

I've looked at the TS Project and DTS Bundle but these don't seem very flexible and I'm worried I'll have to switch to something else later as TypeScript moves in another direction. Plus I'm not keen on the single file approach. But I'm not ruling them out entirely.

Upvotes: 0

Views: 431

Answers (1)

blakeembrey
blakeembrey

Reputation: 424

I wrote typings which has the express goal of solving definition files in TypeScript (https://github.com/typings/typings). It's hard to tell if it'll work with what you're asking though, since I don't know how you consume the other projects you have. If you want to be able to use dependencies and package it them in dependencies of your other projects, all without having to make a single "declaration" generation step and no conflicts, it might be worth trying it out.

The only overhead of it right now is having to convert DefinitelyTyped into external module declarations, since they're incompatible.

Upvotes: 1

Related Questions