Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScript @types version related to Library version

Can anyone explain the versioning behind TypeScript @types https://github.com/DefinitelyTyped/DefinitelyTyped

For example: I assumed that if I was using [email protected] then I would been to install @types/[email protected].

Howerver, this version does not exist. It get worse. for example, [email protected] and @types/[email protected]. What does that mean? What version is this targeting?

How, can I make sure that I'm installing the correct version of the Types for the library version?

like image 258
Garry Taylor Avatar asked Jun 30 '17 14:06

Garry Taylor


People also ask

What are @types TypeScript?

What is a type in TypeScript. In TypeScript, a type is a convenient way to refer to the different properties and functions that a value has. A value is anything that you can assign to a variable e.g., a number, a string, an array, an object, and a function. When you look at this value, you can say that it's a string.

What are @types in npm?

The @types npm organization is for obtaining type definitions with npm . Using these type definitions is a feature is coming in TypeScript 2.0. This will replace the current projects/tools such as typings and tsd, though these will continue to be supported for some time.

Does TypeScript have a standard library?

TypeScript contains types for standard libraries, such as the DOM. TypeScript uses these types when type checking code that interacts with these libraries. By default, the standard types that are checked depend on the target compilation option.


1 Answers

Unfortionaly it may be just a "doing it wrong" matter. Generally, It's a good practice to give the @types version the same version of the library itself. But regarding the patch part of the semantic version, it will differ in most cases.

Possible causes why versions may differ:

  1. There are no updates in types so the library has been patched for example but the @types one hasn't.
  2. @types library is not well maintained.
  3. @types library has many bugs and patches.

Nice to mention:

You can definitely contribute to any @types library and help to keep it well versioned.

like image 64
Mouneer Avatar answered Oct 03 '22 19:10

Mouneer