Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

typings vs @types NPM scope

In some cases typings is used for handling TypeScript definitions (e.g. angular/angular2-seed).

In other cases scoped NPM @types packages are used with no typings involved (e.g. AngularClass/angular2-webpack-starter).

What are the practical differences between them? Does one of them offer benefits for TypeScript development that the other doesn't?

like image 903
Estus Flask Avatar asked Sep 01 '16 01:09

Estus Flask


People also ask

What does @types mean 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. Follow this answer to receive notifications.

What is @types in Node_modules?

This @types scoped package is where we can find a ton of useful type definitions, such as for example the type definitions of node that allow us to use require for example.

What is Typings in TypeScript?

Typings was just a tool to install those files. It is now best practice to just use npm. When you have installed those files, which basically only means downloading them and placing them in your project, the TypeScript compiler will understand* that external code and you will be able to use those libraries.

What does @types mean in node?

As taken directly from the @types/node npm package: This package contains type definitions for Node. js (http://nodejs.org/). This package is used to load in all type definitions when using typescript in node. When you add other packages, you also have to add their typings if they do not include them by default.


1 Answers

@types is the new way to install the definitions in typescript 2.0. It unifies the management of definitions and packages. So that you do not need multiple tools and config files. Only going to need npm and package.json instead of having to have npm, package.json, typings, typings.json. It basically makes installing and managing definitions easier but it is the same as typings.

You can read more about it here: https://blogs.msdn.microsoft.com/typescript/2016/06/15/the-future-of-declaration-files/

like image 126
ordepim Avatar answered Oct 04 '22 21:10

ordepim