Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should typescript @types packages version match their non types packages?

Do @types use the same versioning as the untyped package?

npm i bluebird @types/bluebird -S gives me

"@types/bluebird": "^3.5.0",
"bluebird": "^3.5.0",

Seems pretty reasonable.

npm i request @types/request -S gives me

"@types/request": "0.0.41",
"request": "^2.81.0",

Now this scares me a bit. Does this mean that we only have request types for request version 0.0.41?

like image 218
ClickThisNick Avatar asked Mar 13 '17 16:03

ClickThisNick


People also ask

Should TypeScript be a dependency or devDependency?

Yes, TypeScript is a devDependency and you can add it to your project using this command- 'npm install typescript --save-dev'. But before installing this compiler, you need a copy of Node. js as an environment to run the package.

What does @types mean npm?

Summary: 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.

Should types be saved as Dev dependencies?

In short, you should save a module as a devDependency when it's only used for development and testing; everything else should be a dependency. You might think this is straightforward, clear guidance, but like for users of my module, things can get murky in real life.

Do NPM packages work with TypeScript?

An NPM module can additionally supply TypeScript type information via a declaration file — additional TypeScript code that isn't executable, but simply describes the types to apply to the JavaScript code. A module specifies a declaration file with the types property in package. json .


1 Answers

Should typescript @types packages version match their non types packages?

No. TypeScript types for JS packages is best effort and depends on

  • official js documentation (commonly lacking)
  • Community interest in the package

So version mismatches are fine as long as you are aware of their best effort nature.

like image 176
basarat Avatar answered Sep 23 '22 17:09

basarat