Travesty3 Travesty3 - 1 year ago 368
TypeScript Question

How to manually update a deprecated typings package

I have a NodeJS application that I'm writing in TypeScript. It uses many Node packages. Not all of these packages have Typescript definitions, so I use Typings to get the separate definition files.

When I deploy my application to the production server, I have a Git hook that runs

npm install
typings install
, and
, since these are not included in the Git repository.

When a new version of a Typings definition file is released on DefinitelyTyped, I get warnings when it runs
typings install
that my definitions files are deprecated (updated, replaced, or removed):

typings WARN deprecated 6/30/2016: "registry:dt/bluebird#2.0.0+20160319051630" is deprecated (updated, replaced or removed)
typings WARN deprecated 7/5/2016: "registry:dt/knex#0.0.0+20160622193910" is deprecated (updated, replaced or removed)
typings WARN deprecated 7/20/2016: "registry:dt/node#6.0.0+20160613154055" is deprecated (updated, replaced or removed)
typings WARN deprecated 7/19/2016: "registry:dt/lodash#3.10.0+20160619033623" is deprecated (updated, replaced or removed)

What can be done about this? Is there an easy way to update them all? It looks like the typings.json file specifies a version number for the package after the # sign and a date after the + sign. If a new definitions file gets uploaded to DefinitelyTyped, isn't it usually safe to assume it's more accurate or more complete than the previous version?

Is there even any sanctioned way to update these manually, aside from
typings uninstall --save
followed by
typings install --save
for each package? Seems like a hassle, and there should be some easy way, something like
typings update [package-name]

Answer Source

No update command

There is no update command, there is an issue on Typings about it, containing both unix and powershell scripts to automatically do some kind of update as well.

Specific install command

As you can see in the CLI options, you can however update the type definition for a specific package with a specific source and semver range.

If the source is Definitely Typed you would prefix the package with dt~. While if you have the semver version ^3.10.0, you would further suffix the package name with @^3.10.0.

Depending on if it's a regular or development dependency you would also add --save or --save-dev respectively. While you would further also add --global if it's a global such dependency. This should be readable in the typings.json file

To update the lodash package you mentioned above to the latest type definition with semver version ^3.10.0 you would write:

typings install dt~lodash@^3.10.0 --save


typings install dt~lodash@^3.10.0 --save --global

if it's a global dependency.

This will update the hash and date of typings.json and install that latest definition for the given semver range. While if there is no update to be found, there is no change to the file. If you are set on automating this update process you could thus write a script which tries to do these updates regardless.


Note that Definitely Typed type definitions not necessarily always are correctly tagged with versions. Potentially completely lacking tagged versions or having big gaps between them. Could for instance also be that an untagged version is newer than the latest tagged version, this is currently the case for lodash at Definitely Typed (25th June, 2016).

You can easily discover which tagged versions exist for a given package at a given source with:

typings view <source>~<package> --versions

for the package lodash with Definitely Typed as the source it would thus be:

typings view dt~lodash --versions

To see untagged versions that could be more up-to-date I think you have to actually inspect the corresponding directory at the Definitely Typed repo, where it could be mentioned in the latest commit or stated at the top of the file.

Easy in TypeScript 2.0

Should also be mentioned that TypeScript 2.0, currently in beta, has an easier solution integrated into npm (in collaboration with the Typings author and TSD authors). Where you essentially get the Definitely Typed packages as @Types/packageName from npm while also being able to automatically get types from npm packages directly. Thus enabling you to simply use package.json and npm to directly manage your type definitions. In which case npm update will get exactly the behavior you originally requested.

Would however want to note that I read in the comment section of TypeScript Beta announcement that at least some version of the Beta did not warn for out-of-date Type Definitions, even for semver major updates. Meaning if you wanted type definitions for lodash version 4 and instead got for lodash version 3, there would be no warning. Just something to potentially have in mind.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download