blackHawk
blackHawk

Reputation: 6307

How to use express with typescript

So the definition files moved from tsd to typings and now to @types, how can I use @types in node/express project, what is preferred at this time, also why we moved from tsd to typing and now @types

Thanks,

Upvotes: 1

Views: 378

Answers (1)

Remo H. Jansen
Remo H. Jansen

Reputation: 24979

why we moved from tsd to typing and now @types

  • TSD was created because in the early days you had to manually go to GitHub and download dts files by hand.

  • Typings was created because dts lacked some important features. For example, not all type definitions were available at DefinitelyTyped but Typings allows you to download from multiple sources. However this was a problem because now we had two tools and multiple dts sources.

  • @types was created by Microsoft to stop the tool madness and to improve the developer experience.

DTS and Typings provide their own command line tools. @types uses npm.

what is preferred at this time

At this time, the recommended solution is @types

The great thing about @types is that if an npm module includes dts files then you don't need to install dts at all. For example:

$ npm install inversify

The inversify npm module includes dts files so you don't need to install anything extra.

If dts files are not included in an npm module (e.g. JQuery), you don't need an extra tool like typings or dts. You can just use npm as well:

$ npm install jquery @types/jquery

how can I use @types in node/express project

All you need is an npm command:

$ npm install express @types/express

Remember that for @types to work you will need TypeScript >= 2.0!

Upvotes: 1

Related Questions