4

I'm in the process of converting an existing project to TypeScript with many bower and npm dependencies (bower.json and package.json). According to the tsd github page,

TSD supports discovery and linking of definitions from packages installed with node or bower. Use the link command and your tsd.d.ts will be updated with paths to the files in the node_modules or bower_modules folders.

However when I run the command tsd link after tsd init it just says no (new)packages to link even though my package.json is chalk full of modules. This led me to discover, maybe it does not do what I think it does.

This feature will scan package.json and bower.json files for a typescript element. This element then contains definition or definitions sub-element that contain relative path(s) to .d.ts files:

What? What is the purpose of this link feature if it doesn't just get type definitions from my package.json? Is this command merely to pull tsd configurations from my package.json instead of in my tsd.json file? What then, is the point, other than eliminating the tsd.json file?

So if it's not tsd link, I'm asking if there is any better way to automatically include tsd definitions for all my dependencies. It seems kind of crazy to me that these would all be managed by hand.

FlavorScape
  • 13,301
  • 12
  • 75
  • 117

1 Answers1

2

tsd link is not a magical command. I assume just like you when I see this command first time.

If you install new packages via bower or NPM, and the package bundled with .d.ts and also have a "typescript": { "definition": "..." } in the config file, that .d.ts will include into your tsd.d.ts file like below:

/// <reference path="jquery/jquery.d.ts" />
/// <reference path="../bower_components/angular/angular.d.ts" />

If the package doesn't serve a d.ts file and definition configuration, this command can do nothing.

Edward
  • 4,887
  • 3
  • 17
  • 25