What is the best solution for a type definition management system (e.g. tsd) for Typescript?

When it comes to using Typescript, we need to think about how to allow type definition files (* .d.ts).

As far as I know, there are several systems for managing the typescript definition system, as shown below.

  • TSD
  • typing
  • @types

I think tsd is the oldest and this is the source. But why give birth to typings ? I think creating a definition file for typing is a bit more complicated.

And what is @types really?

Then what is the best solution for this?

+7
typescript typescript-typings tsd
source share
1 answer

The history of the type management ecosystem around TypeScript is very long.

First, there was a (still) monolithic repository called DefinitelyTyped , which was used as a hub for all developers who wanted to introduce their own typifications for different libraries.

Because of this repository, a typing manager named tsd takes directly the icons from this repository and saves them locally in your project.

Meanwhile, DT repo exceeded scalability and had to be restructured . The discussion continued on how the d.ts. file should look d.ts. , so at some point there was a need for another way to include captions in your project. Another problem was the versioning of the libraries and the TypeScript compiler itself.

Then at some point Blake Embry created a new teen manager called typings , which had DefinitelyTyped support, and a new proposed way to structure d.ts The new structure allowed the use of two types of modules - global (most of the specific) and modules that must be encapsulated.

TypeScript beta 2.0 was later announced by Microsoft. The TypeScript team recognized the need for a different way of handling input files. What they did is the @types npm scope that they announced was a new way to handle the type . @types currently only works with TypeScript 2.0.

Declaration files (.d.ts files) are a fundamental part of using existing TypeScript JavaScript libraries, but getting them has always been a place where, as you know, there was room for improvement. As we get closer to TypeScript 2.0, we are very pleased to demonstrate the peak of our plan to simplify the situation. Getting TypeScript 2.0 type declarations will not require tools other than npm.

So the answer to your question is:

If you use TypeScript below v2.0, use typings , but if you use 2.0, use @types

+8
source share

All Articles