Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Knip doesn't report @types packages as unused when types are bundled #942

Closed
6 tasks done
nihalgonsalves opened this issue Feb 10, 2025 · 4 comments
Closed
6 tasks done
Labels
bug Something isn't working

Comments

@nihalgonsalves
Copy link

Prerequisites

Reproduction url

https://stackblitz.com/edit/github-rr55fg3x?file=package.json,index.ts

Reproduction access

  • I've made sure the reproduction is publicly accessible

Description of the issue

(I initially reported this as a feature request in #936)

https://knip.dev/guides/handling-issues#type-definition-packages implies that these should be reported as unused, but I cannot get Knip to report them. I tried a package from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/notNeededPackages.json and a package that initially prompted me to file the first issue:

  "devDependencies": {
    "@types/ajv": "^0.0.5",
    "@types/eslint__js": "^8.42.3",
    "knip": "^5.43.6"
  },
  "dependencies": {
    "@eslint/js": "^9.20.0",
    "ajv": "^8.17.1"
  }

Assuming the dependencies are used somewhere, I'd expect the @types/ packages to be reported as unused, as both packages bundle their types 1 2

Footnotes

  1. https://github.com/ajv-validator/ajv/blob/master/package.json#L6

  2. https://github.com/eslint/eslint/blob/main/packages/js/package.json#L6

@nihalgonsalves nihalgonsalves added the bug Something isn't working label Feb 10, 2025
@nihalgonsalves nihalgonsalves marked this as a duplicate of #936 Feb 10, 2025
@webpro
Copy link
Member

webpro commented Feb 12, 2025

Thanks for the report and the report, @nihalgonsalves. Applied some fixes and did some smoke testing, things look better now. Any chance you could give it a shot on one ore more of your project(s)? You could install like so:

npm i -D https://pkg.pr.new/knip@fc95526

It's interesting how it seems to catch some unused dependencies already: https://github.com/webpro-nl/knip/actions/runs/13290036970

@nihalgonsalves
Copy link
Author

yup seems to work now, thank you! tried it on this commit~1: nihalgonsalves/esconfig@0855254

Unused devDependencies (1)
@types/eslint__js  package.json:36:6

@webpro webpro closed this as completed in fc95526 Feb 12, 2025
@webpro
Copy link
Member

webpro commented Feb 12, 2025

🚀 This issue has been resolved in v5.44.1. See Release 5.44.1 for release notes.

Using Knip in a commercial project? Please consider becoming a sponsor.

@webpro
Copy link
Member

webpro commented Feb 12, 2025

Thanks again Nihal! LFG 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants