jeffijoe / typesync

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

Avoid installing deprecated type packages #114

Closed silverwind closed 4 months ago

silverwind commented 4 months ago

According to https://github.com/jeffijoe/typesync/issues/79, deprecated type packages should not be suggested or installed, but I notice it still does, for example with this package.json:

{
  "devDependencies": {
    "escape-goat": "4.0.0",
    "escape-string-regexp": "5.0.0"
  }
}
$ npx typesync --dry
»  TypeSync v0.12.1
»  —— DRY RUN — will not modify file ——
✔  2 new typings can be added.

📦 test — package.json (2 new typings added)
├─ + @types/escape-string-regexp
└─ + @types/escape-goat

✨  Run typesync again without the --dry flag to update your package.json.

Both type packages are deprecated as seen during npm install:

npm warn deprecated @types/escape-goat@2.0.1: This is a stub types definition. escape-goat provides its own type definitions, so you do not need this installed.
npm warn deprecated @types/escape-string-regexp@2.0.1: This is a stub types definition. escape-string-regexp provides its own type definitions, so you do not need this installed.
jeffijoe commented 4 months ago

I think I know what the issue is. When there's no matching version of the typings package, it'll fall back to checking the first one in the list of versions. The code assumes that to be the latest version, but NPM seems to be returning them in the other order.

EDIT: Nevermind, here we're sorting them first.

EDIT 2: Looks like the API no longer returns the deprecated top-level field in the JSON. Will have to check in the package version itself.

jeffijoe commented 4 months ago

Fixed in v0.12.2. Thanks for reporting!

silverwind commented 4 months ago

Thanks, working with 0.12.2!


$ npx typesync@0.12.2 --dry
»  TypeSync v0.12.2
»  —— DRY RUN — will not modify file ——
✔  No new typings to add, looks like you're all synced up!