0

I'm upgrading an old typescript project. Many years ago, most packages had corresponding @types packages. Nowadays, typings are usually included in the main package, therefore typing packages got obsolete.

A typical example is yup. Many years ago it needed @types/yup, but now it's deprecated.

I have 30+ typing packages in my project, and because I don't want to manually clean them, I'm asking:

  1. What if I just leave them in pakages.json? I guess there is a big chance they would mislead typescript and IDE, right?
  2. Is there a command or script to list or clean deprecated packages?
Dan
  • 55,715
  • 40
  • 116
  • 154
  • Mmm, maybe `npm outdated` or `npm-check`: https://stackoverflow.com/questions/35236735/npm-warn-message-about-deprecated-package – kelsny Jan 04 '23 at 15:45
  • `I don't want to manually clean them,`, You only have 30, it's surely not that hard to manually edit `package.json` to delete them, and run `npm i` to update. Or am I missing something..? – Keith Jan 04 '23 at 15:47
  • If this is something you need to do a lot, one idea is to just create a simple node script,.. First load `package.json`, search all packages for `@types/` then scan the directory for that package, if there are any `.d.ts` files remove from `package.json`, finally `npm i` to update `node_modules` – Keith Jan 04 '23 at 15:52
  • @Keith I was expecting someone to solve this common issue already... – Dan Jan 04 '23 at 15:57
  • @vera. `npm-outdated` shows packages that have a newer version released, but not deprecated ones. However, deprecated packages can be seen in `npm i` output. – Dan Jan 04 '23 at 16:01
  • @Dan Might be. But when I was using `pnpm` there were lots of things that I wanted to do inside a mono-repo automatically, and though, oh, somebody would have done this already. But after searching for ages, decided it was quicker just to make a simple CLI tool that did things I wanted. In the end I'm glad I did, as it just makes my workflow work the way I want.. Also my previous suggest of searching for `.d.ts` files might not be required, I think the `types` prop of a package.json will tell you if it's got types built in, so that makes it a tad easier. – Keith Jan 04 '23 at 16:03
  • Edit: actually forget about the bit about looking for `types` in package.json, just looked at yup, and it just places the `.d.ts` files in the same directory as `.js` files, there is no `types` prop, or anything in package.json to say it's got types, so a search for `.d.ts` files seems the most reliable way to know if a package has built in types.. :( – Keith Jan 04 '23 at 16:19

0 Answers0