5

I am using TSD to manage the TypeScript definition files for a web application I am developing.

Should I check the TypeScript definition files for the external libraries I am using (managed via Bower) into git in addition to the tsd.json file?

Similar discussions exist for Bower and NPM dependencies, where the NPM documentation says no, and afaik Bower no longer gives a recommendation (used to say yes).

The definition files are quite lightweight, so I am leaning towards checking them in. Any opinions?

muenchdo
  • 2,161
  • 1
  • 17
  • 30

2 Answers2

8

If a developer should run npm install after checking out your repo, why not have tsd install run automatically? It's easy to add it to scripts in package.json:

// package.json
"scripts": {
  "postinstall": "tsd install"
}

The argument for not checking in generated files and dependencies is not merely to reduce the weight of the repository. It's also about trusting a script to keep things up-to-date, rather than human decision. And it reduces noise in commits when minor changes occur in the generated files.

A contrary argument could be made: if you're concerned that the tsd resources will go missing, checking them into your repo will guard against that. But the paranoid should check in the npm modules as well.

Robert Penner
  • 6,148
  • 1
  • 17
  • 18
  • Just a note... since npm scripts run w/ `node_modules/.bin` in the path, there is no need for other developers to have tsd installed globally. (unless they are adding new definitions to the repo/project) – Brocco Sep 24 '15 at 11:53
  • @Brocco That was the "missing link"! One reason I didn't mention in my question was that I didn't want do require developers to install `tsd` globally. Thanks! – muenchdo Sep 25 '15 at 10:14
  • how can you know that the developer has tsd installed globally? do you include that in the devDependencies of npm's package.json ? – danfromisrael Jan 28 '16 at 12:06
  • @danfromisrael As per Brocco's comment above, tsd doesn't have to be installed globally to run as an npm script. – Robert Penner Feb 11 '16 at 06:38
  • I don't think that `.d.ts` files should be checked into git in all situations, but won't `postinstall` also run when users `npm install` the published package? Seems like an unnecessary step for users who just want to consume the transpiled javascript in their own projects. – dvlsg Apr 14 '16 at 17:47
  • The OP said "The definition files are quite lightweight." – Robert Penner Apr 15 '16 at 04:50
  • Now that `tsd` is deprecated, it's recommended to migrate to `typings`. http://stackoverflow.com/questions/35598876/why-is-tsd-deprecated – Robert Penner Apr 15 '16 at 04:52
2

Yes,

Since I include "typings/tsd.d.ts" in tsconfig.json its now part of the build process, And I don't wont to maintain .gitignore with subdirectories of "typings/" , simple its better ...

and its more like a vote that an answer :)

As an example : I recently added in a project definition from the npm package instead of the definitely typed repo , but I added it to typings/tsd.d.ts because is the only definition file I reference in tsconfig.json ... ergo I can't relay any more in tsd to keep the defintions in sync, then.. check it in ... I could just simply add another definition file choosing arbitrary where to place it and reference this other definition file compilation too, but is more work more complicated and the result is the same, but only one file to keep the reference chain working.

Dan
  • 2,818
  • 23
  • 21