Suggestion: use tsd for type definitions
Closed this issue · 11 comments
Hey @joewood, thanks for the suggestion! I'm not too familiar with tsd but it looks interesting. I'd be open to adding it, feel free to submit a PR!
Ok, tsd is sweet :) I added support for it here 176b6a1
I'll work on getting the code paths switched over to the new typings locations later.
Thanks for the great suggestion! Cheers.
Question for you though: I have some local typings which aren't part of DT repo. Do you think I should have them checked in under the typings folder?
Depends on what you mean by local types.
- For types for external libs that are missing from DT, I would suggest you add them and send a pull request. The way I handle this is to clone the DT repo, add a new dir and the missing types, then configure tsd to use your local cloned repo instead of the official one.
- For private type definitions (non-public libraries) I still add these into the
typings
directory. Where I can I add the configuration for these types into thepackage.json
file and usetsd link
to pull the typings into thetsd.d.ts
file. - For private Typescript packages I run dts_bundle on the dependent files. This generates a single
.d.ts
file which I think pull in with annpm install
andtsd link
.
I also use grunt, browserify and contrib_watch in my build process too, along with the tsify plugin. This seems to be working well with react based apps.
Hmm, so I tried the tsd link approach for the non-public definitions but it seemed to only link to ones under node_modules. Is that the right behavior? I did a similar approach to what you have said in your second bullet point.
Right, tsd link is for node_modules
that have been installed that carry their own type definitions. I use npm for non-public packages, even across local directories. npm install /path/to/private/package
. With react's modular approach this works really well.
ok cool. one more question if you don't mind :) for tsd should it be reinstall or update ?
currently in the readme i have it as so:
node_modules/tsd/build/cli.js reinstall --save --overwrite
I'd really not like to add another step to install one package as global...
I use:
tsd update -so
I also use 0.6, so I install it with
npm install -g tsd@next
But, if you want to avoid the global install you could use:
npm install
node_modules/.bin/tsd update -so
Hopefully tsd will support the npm script field in the future to make this easier.
I also check these type definitions into source control, as they tend to be quite volatile.
Hm, ok. I will make that change. Volatile? Really? It seemed this was a nice way to not have them in source control ala node_modules.
In an ideal world I would remove them.
Maybe, one day, everybody will be shipping type definitions and this won't be an issue. :-)
the problems of working on the bleeding edge :)
thanks for your help!