Using the Latest Version of TypeScript Definition with Old JavaScript Libraries

I am using an older version of AngularJS - v1.3. Search for matching script type definition files.

Will the definition of the latter type of script be compatible with the old library version?

https://www.nuget.org/packages/angularjs.TypeScript.DefinitelyTyped/

It is difficult to find comparisons between the version of the Angular JS type-script definition file and the version of the Angular JS library. Can we continue to develop the latest version of typescript.

EDIT: I had to compare two nuget repositories and took the version where angular.d.ts comment changed from // Type Definitions for Angular JS 1.3+ to // Type Definitions for Angular JS 1.4+

+4
source share
3 answers

You can usually search for definitions of previous versions by running the following command with tsd :

tsd query angular -v all 

Then install the version you want (e.g. tsd install angular -v 1.0.0 ).

There is a problem though. For some reason, only two angular versions are available:

 - angularjs / angular - angularjs / angular-v1.0.0 - angularjs / angular-v1.2.0 

For this reason, I would suggest angular.d.ts look at the commit history of angular.d.ts and find the last definition file before switching from 1.3 to 1.4. Knowing when angular 1.4 is released helps.

Thus you will find this definition file for version 1.3.

+3
source

Use the ref attribute to indicate the exact version of the type definition file that corresponds to the branch on git. In your case, you can use the following steps.

  • Add the required tsd dependencies using

    tsd install angular --save

  • The save step will create a tsd.json file with the structure below:

  { "version": "v4", "repo": "borisyankov/DefinitelyTyped", "ref": "master", "path": "typings", "bundle": "typings/tsd.d.ts", "installed": { "angularjs/angular.d.ts": { "commit": "77ec1408257c677f8fd8d6798ebaf6bd87c11b9d" } } } 
  1. Update the ref attribute to the required version of the angular type definition . In your case, most likely it should be 1.3.0

  2. Run tsd install again to download the necessary type definitions

+2
source

What I did is a bit like a long way and not quite your scenario, but it worked for me and, I hope, people in my situation will land here ...

In my script, I ripped out NuGet as the typescript definition manager and replaced it with tsd, and I needed a specific version of lodash typescript definition (0.4.1), but tsd installed the latest version. Since the version of how it works is not yet supported during installation, and tsd uses commit hashes to keep track of which version you are using, I used nuget to find the version I need:

NuGet Package Manager in Visual Studio

then replaced the "commit" hash in tsd.json with the git commit specified in the description:

tsd.json file

It was a bit painful because I had to enter the hash manually, but it ensured that I had the version I needed.

0
source