Definitelytyped: What is the meaning of the versions in definitely typed packages

Created on 9 Dec 2016  ·  3Comments  ·  Source: DefinitelyTyped/DefinitelyTyped

I think versions of definitely typed packages should not match the version of the real package. For example in the time I am writing this issue latest version of lodash is '4.17.2and the latest version of@types/lodashis4.14.43. This probably means that the typings are forlodash-v4.14.43`. So it is confusing when we want to change a typings package because there are no good ways to increment the typings package because it is meant to be the real version of the package. This will break installing npm packages in many of the projects.

I suggest to typings packages not follow the exact versions of the real packages. For example:

lodash version: 4.14.43

@types/lodash version: 4.1.1

But in the .d.ts file we should explicitly write the compatible lodash package version.

Also we can have @types/lodash-3 etc for older version of lodash

Most helpful comment

The policy for version numbers is to try to keep the first two numbers in line. @types/lodash being at 4.14.x means that it should work with lodash 4.14 and above. The last digit reflects updates to the package structure (IE: maybe someone made a more accurate type definition to the 4.14 changes).

Given that DT is community supported, it seems that one of the following must be true:

  1. lodash didn't introduce anything that would require type related changes
  2. lodash did introduce changes but no one in the community needed/wanted said functionality
  3. lodash did introduce changes but there is a desire to keep the types compatible with the slightly older version

I would guess its #2.

As to @types/lodash-3, the way that modules are resolved, you would need to be performing something like import * as _ from "lodash-3" for said types to be picked up.

All 3 comments

The policy for version numbers is to try to keep the first two numbers in line. @types/lodash being at 4.14.x means that it should work with lodash 4.14 and above. The last digit reflects updates to the package structure (IE: maybe someone made a more accurate type definition to the 4.14 changes).

Given that DT is community supported, it seems that one of the following must be true:

  1. lodash didn't introduce anything that would require type related changes
  2. lodash did introduce changes but no one in the community needed/wanted said functionality
  3. lodash did introduce changes but there is a desire to keep the types compatible with the slightly older version

I would guess its #2.

As to @types/lodash-3, the way that modules are resolved, you would need to be performing something like import * as _ from "lodash-3" for said types to be picked up.

Thank you for your great answer. This question comes in my mind because recently an update to lodash typings broke my code (https://github.com/DefinitelyTyped/DefinitelyTyped/commit/34124e057f3f2baf4d1b0f17616a00221c04690c). Apparently, we should write more tests for lodash typings.

For context, this other thread makes it sound as if the policy of trying to keep version numbers somewhat in sync is only followed by some packages.

Was this page helpful?
0 / 5 - 0 ratings