0

I am a new to TypeScript and a bit confused. If my version of TypeScript is 1.0.1 (say I'm stuck on VS2012), how do I use tsd to find type definitions for a library that given I require tsc 1.0.1.

Without version information, I will often get type definitions for tsc1.4.

I figure there must be a way to do this in tsd, but I have not been able to figure it out.

Cheers!

dacox
  • 502
  • 1
  • 6
  • 14

2 Answers2

0

how do I use tsd to find type definitions for a library that given I require tsc 1.0.1

You can't easily. You need to run tsd install somedefinitionyoucareabout -soa and then change the git sha saved in tsd.json to some thing that is from the 1.x branch: https://github.com/borisyankov/DefinitelyTyped/tree/1.0.1

That said you really should consider updating to TypeScript latest.

basarat
  • 261,912
  • 58
  • 460
  • 511
  • Thanks! Shortly after I asked this question I took a look at `tsd.json` and changed the branch from `master` to `1.0.1`. At first glance, it _seems_ to have properly pulled down TypeScript 1.0.1 compatible definitions. Do you have any experience with this? – dacox Jul 23 '15 at 17:22
  • And in fact better :) – basarat Jul 24 '15 at 03:17
0

If you are trying to download TypeScript type definitions for an older version of TypeScript with tsd, you may do the following.

If you look inside tsd.json you will see the key "ref", which is set to "master".

{
  "version": "v4",
  "repo": "borisyankov/DefinitelyTyped",
  "ref": "master",
  ...
}

This refers to the master branch of borisyankov/DefinitelyTyped.

There are other branches of borisyankov/DefinitelyTyped such as 1.0.1 which target previous releases of TypeScript.

Simply modify tsd.json to point to another branch, and it will retrieve type definitions specific to that version of TypeScript.

{
  "version": "v4",
  "repo": "borisyankov/DefinitelyTyped",
  "ref": "1.0.1",
  ...
}

After you have done this, you can install a type definition with --save and inspect the commit hash in tsd.son to confirm.

dacox
  • 502
  • 1
  • 6
  • 14