jeffijoe / typesync

Install missing TypeScript typings for dependencies in your package.json.
MIT License
1.53k stars 22 forks source link

Use same major/minor version with corresponding package #86

Closed munierujp closed 10 months ago

munierujp commented 2 years ago

Why

Because 10.12 is at the end of the first line, the npm version of the @types/node package will also be 10.12.x. Note that the first-line comment in the index.d.ts file should only contain the major.minor version (e.g. 10.12) and should not contain a patch version (e.g. 10.12.4). This is because only the major and minor release numbers are aligned between library packages and type declaration packages. The patch release number of the type declaration package (e.g. .0 in 10.12.0) is initialized to zero by Definitely Typed and is incremented each time a new @types/node package is published to npm for the same major/minor version of the corresponding library.

https://github.com/DefinitelyTyped/DefinitelyTyped#how-do-definitely-typed-package-versions-relate-to-versions-of-the-corresponding-library

Example

current package.json:

{
  "dependencies": {
    "node-fetch": "^2.5.0"
  }

expected package.json after npx typesync:

{
  "dependencies": {
    "node-fetch": "^2.5.0"
  },
  "devDependencies": {
    "@types/node-fetch": "^2.5.12"
  }

actual package.json after npx typesync:

{
  "dependencies": {
    "node-fetch": "^2.5.0"
  },
  "devDependencies": {
    "@types/node-fetch": "^2.6.1"
  }
jeffijoe commented 11 months ago

TypeSync should already attempt to install the most compatible version, is this still an issue?

Chaxwell commented 11 months ago

I have this

{
  "dependencies": {
    "react-dom": "^16.14.0"
  }
}

and it gave me this

{
  "devDependencies": {
    "@types/react-dom": "^18.2.18"
  }
}

while there is a 16.9.8 version that would be a lot closer I guess ?

jeffijoe commented 10 months ago

Thank you everyone for your reproduction cases! I think I found the issue, working on a fix for this.

jeffijoe commented 10 months ago

I've released typesync@0.12.0 to address this, please give it a try.