This package has been deprecated
TSD is deprecated in favor of Typings (https://github.com/typings/typings) - see https://github.com/DefinitelyTyped/tsd/issues/269 for more information
TypeScript Definition manager for DefinitelyTyped
npm install tsd -g
For previews and history check the release tags.
$ tsd install jquery --save$ tsd query angular -ir$ tsd query angularjs/$ tsd query jquery.*# glob on mac/linux$ tsd query "jquery.*"#install all definitions from tsd.json$ tsd install
tsd binary with help.
$ tsd$ tsd -h$ tsd --help$ tsd --version
Sometimes it looks like this:
Create a new
tsd.d.ts. This is not required but useful to init valid project references before starting to add (external) code, or if you want to edit the config.
$ tsd init
Minimal query for
$ tsd query d3
Get some info about
$ tsd query jquery --info --resolve$ tsd query jquery -i -r$ tsd query jquery -ir
$ tsd query */jquery.*
Hint: if you are using Linux or Mac OS X, use quotes to glob:
$ tsd query "*/jquery.*"
$ tsd query mocha --history$ tsd query mocha -y
$ tsd query *
Note: more info on queries can be found futher-on in this readme.
pixi definition on github:
$ tsd query pixi --action browse$ tsd query pixi -a browse
$ tsd query gruntjs --action visit$ tsd query gruntjs -a visit
$ tsd install mocha
mocha and save to
$ tsd install mocha --save$ tsd install mocha -s
Same as query action:
$ tsd query mocha --save --action install$ tsd query mocha -sa install
Resolve the reference to
jquery, overwrite existing files and save to
$ tsd install angular --resolve --overwrite --save$ tsd install angular -r -o -s$ tsd install angular -ros
Same as query action:
$ tsd query angular --resolve --overwrite --save --action install
sinon definitions all at once, with resolve references, overwrite existing files and save to
$ tsd install mocha chai sinon -ros
Install all definitions from
$ tsd install
tsd installwill work like
tsd reinstall --save --overwrite
Reset the definitions to the commits listed in
$ tsd reinstall --save --overwrite$ tsd reinstall -s -o$ tsd reinstall -so
Update everything in
tsd.json to head version in the repository:
$ tsd update --save --overwrite$ tsd update -s -o$ tsd update -so
TSD supports discovery and linking of definitions from packages installed with
link command and your
tsd.d.ts will be updated with paths to the files in the
$ tsd link
This feature will scan
bower.json files for a
typescript element. This element then contains
definitions sub-element that contain relative path(s) to
If the module exports multiple independent files,eg: for some reason not internally
Cleanup the bundle file (usually
tsd.d.ts): remove paths to non-existent files, and append unlisted definitions. Handy when editing definitions.
$ tsd rebundle
Print current Github rate-limit info
$ tsd rate
Forcefully remove global http cache files
$ tsd purge
There are various ways to select files from the repository index.
TSD uses a (globbing) path + filename selector to query the DefinitelyTyped index. The results can then be modified using various filters:
Note how the definition filename takes priority:
$ tsd query module$ tsd query project/module
For example, consider these definitions:
Notice the pattern, and ignore the
Select definitions using only the module name:
$ tsd query module$ tsd query module-addon
Or use a selector derived from the path format:
$ tsd query project/module$ tsd query other/module
Or simply get everything in a project:
$ tsd query project/
The selector also supports globbing, for example:
$ tsd query project/*$ tsd query project*$ tsd query module*$ tsd query project/module*$ tsd query project-*/plugin*$ tsd query *project*/*$ tsd query project/plugin*$ tsd query other/module$ tsd query */module$ tsd query */module-*$ tsd query */*plugin
Hint: if you are using Linux or Mac OS X, use quotes to glob:
$ tsd query "*/jquery.*"
Note: the semver postfix of definition files is expected to be separated by a dash and possibly a
If there are multiple matches with same module name they will be prioritised:
- The unversioned name is considered being most recent.
- Then versions are compared as expected following these comparison rules.
- Use the
-voption to set a semver-range:
$ tsd query node -v latest$ tsd query node -v all$ tsd query node -v ">=0.8 <0.10"$ tsd query node -v "<0.10"
-d option to set a date-range (find dates using
$ tsd query d3 --history$ tsd query d3 --date ">=2012-01-01"$ tsd query d3 -y$ tsd query d3 -d "<2012-01-01"
-c option to supply sha1-hash of a commit (find a commit hash using
--history), for convenience a shortened sha1 hash is supported.
$ tsd query youtube --history$ tsd query youtube --commit d6ff$ tsd query youtube -y$ tsd query youtube -c d6ff
- For now this only works with commits that actually changed the definition file you selected (eg, listed in
--history) This will be expanded to allow selecting from any commit at a later date.
tsd.json file is automatically created in the root of each project: it configures TSD and it tracks the definitions that are installed (using
To generate a default
$ tsd init
An example configuration the 'node.js' definition installed would look like this:
||Tracks config version for future changes (don't change this).|
||Github user and repo name of the typings repository. Change this if you want to use TSD from a DefinitelyTyped fork.|
||Branch name or other git reference of the repository. Change this to use legacy branches.|
||Path to the typings directory, the definitions will be installed in the appropriate sub-folders. Change this to have typings in your main code directory, but this is not recommended as the mixed styles used in the definitions it will confuse your inspections and lint-tools.|
||Path to a
||no||(not set)||Set to
tsd.d.ts file refers every definition that is installed with
--save for convenient and explicit single reference from code.
/// <reference path="../typings/tsd.d.ts" />
By default it is created in the typings folder but the name and location are configurable in
tsd.json. When adding new references TSD will check the existing references and respects re-ordering (ordering is important for inter-dependent definitions).
This is a optional JSON encoded file to define global settings. TSD looks for it in the user's home director (eg:
%USERPROFILE% on Windows,
~ on Linux), and in the current working directory.
- "proxy" - Use a http
Any standard http-proxy as supported by the request package.
- "strictSSL" - Toggle strictSSL verification:
Enabled by default, setting this option to
false disables strict SSL. Passed to request package.
Useful behind (corporate) proxies that act like man-in-the middle on https connections.
- "token" - Github OAuth token:
The OAuth token can be used to boost the Github API rate-limit from 60 to 5000 (non-cached) requests per hour. The is token needs just 'read-only access to public information' so no additional OAuth scopes are necessary.
You can also set the token using the
TSD_GITHUB_TOKEN environment variable.
You can create this token on Github.com:
- Go to https://github.com/settings/tokens/new
- Deselect all scopes to create a token with just basic authentication.
- (verify you really deselected all scopes)
- (wonder why these presets were set??)
- Enter a identifying name, something like "
TSD Turbo 5000"
- Create the token.
- Copy the hex-string to the
tokenelement in the
- Verify enhanced rate-limit using
$ tsd rate
Change or revoke the token at any time on https://github.com/settings/applications
Note: keep in mind the
.tsdrc file is not secured. Don't use a token with additional scope unless you know what you are doing.
The bare 'no scope' token is relatively harmless as it gives 'read-only access to public information', same as any non-authenticated access. But it does identify any requests done with it as being yours, so it is still your responsibility to keep the token private.
var tsd = ;var api = 'path/to/tsd-config.json';api;
For a practical example see grunt-tsd.
TSD uses Promise/A+ by bluebird. 👈👍
API export is somewhat experimental; take care to lock versions and test on upgrade. If you plan to use TSD as module in a tool or project then feel free to leave a message and coordinate stuff.
- It is recommended you check-in the definitions you install into your VCS.
- Don't forget to move your fixes back to DefinitelyTyped
The Github API has a 60-requests-per-hour rate-limit for non-authenticated use. You'll likely never hit this as TSD uses local caching and the definition files are downloaded from Github RAW urls. If you need some more then a scope-limited Github OAuth token can be used to boost the limit to 5000.
The CLI tool tracks some anonymous usage statistics about what definitions are installed though TSD in Google Analytics (using universal-analytics). There is also a update-notifier service to check for TSD updates.
If TSD is used in a way that needs many unique API calls in a short period (like using
--history on big selections), or shares an internet-connection with multiple users (like in an office) then the rate limit blocks the API. It blocks for 60 minutes after the first request of the total 60.
For these cases TSD has an option to use a Github OAuth token and raise your local rate-limit from 60 to 5000 per hour. See the
.tsdrc-section elsewhere in the readme.
v0.5.7 there are two ways to configure the location of the proxy server:
- Use a environment variable. TSD support the conventional fields: pick one of
- Use a global
.tsdrcfile and set a
proxyvalue (see the tsdrc-section elsewhere in the readme).
v0.6.0 strict SSL verification can be disabled in
strictSSL variable (see tsdrc-section).
Yes, and no (and later yes again)
There is basic support for parsing semver-postfixes from the definition file names, and you can filter on this using semver ranges with the
--version option: Try it with the 'node' definitions.
It works well but is not used much in the current DefinitelyTyped repository. The DefinitelyTyped group is working on a meta-data source that will solve this (the Nuget exporter is waiting for this too).
The cache is stored in the users home directory (like
$ npm). Use
$ tsd settings to view the current paths. Use the
--cacheDir to override the cache directory, or
--cacheMode to modify caching behaviour.
Long delayed release of major overhaul: migrated code to external module style and reworked many features, subsystems and dependencies. Development in dev/next branch.
installcommand to CLI
- improved module-name pattern matching
- refreshed CLI interface, formatting, help
- reworked http download/cache
- switched many modules, added
- replaced ugly node-gyp sub-dependency
Current release versions. See the release tags fore more details.
- Original version by @Diullei.
v0.3.x (old readme here):
$ npm install firstname.lastname@example.org -g
To rebuild clone the repos:
$ npm install
Build, lint and test:
$ grunt test
$ grunt build
Run in dev folder:
$ node ./build/cli.js query d3 --dev
Install dev folder to global cli:
$ npm install . -g
TSD uses gruntfile-gtx to test separate test suites sets during development:
$ grunt -h
Example: run only api tests:
$ grunt gtx:api$ grunt gtx:cli$ grunt gtx:tsd
It is recommend you use an intelligent parsing IDE (WebStorm or VisualStudio) and a big screen (or two) on a properly powerful workstation.
Code looks best with tabs rendered at 4 spaces (3 is nice too, or 6 or 8.. I don't really care, because smart-tabs are awesome like that). The gruntfile uses slightly harsh JSHint and TSLint settings to enforce code style, but there is an
.editorconfig to elevate some of the pain.
Master branch is the release version, new development happens currently in dev/next branch: probably broken and regularly rebased for near future.
Contributions are very welcome; please discuss larger changes in a ticket first. Fixes and simple enhancements are always much appreciated. Please make sure you work in the right branch.
Note: Contributions on the definition files go directly to DefinitelyTyped.
The TSD CLI tool collects definition usage information, like the queries made to the repo and the definitions that get installed. The information collected amounts to about same level of detail as services like npm or github would collect (maybe even less as we don't track a user id).
The API does not track anything.
Changes to the policy should be announced in release notes, and ideally ask confirmation on the first CLI use.
Keep in mind we're just devs like you and are working on this in our spare time; we run this project out of love and duty and most of all for fun as learning experience. The stats give us helpful insights into the usage of TSD, and of course the growing numbers and graphs motivate us to spend our time on further development.
Please close read the relevant sections of the readme, especially on OAuth 'scope'.
The optional Github OAuth token is only used to authenticate with the Github API. The token is not stored anywhere but the local machine. It is your responsibility to keep your token safe.
Using an OAuth token with additional scope is neither advised nor supported, even though it could make TSD work with private repositories. But it might also leak repo or content names to analytics or leave a bare http cache in your temp dir. If this bothers you please review the license and/or leave a message.
Licensed under the Apache License, Version 2.0.
- note: there is some imported MIT licensed code by myself, Bart van der Schoor
Copyright (c) 2012 by Diullei Gomes.
Licensed under the MIT License.