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

Consider @types packages for used dependencies as used even without TypeScript #866

Open
alexeyr-ci opened this issue Dec 14, 2023 · 0 comments
Labels

Comments

@alexeyr-ci
Copy link
Contributor

Bug Description

Currently @types/... packages for used dependencies are only considered to be used when the TypeScript parser is used:

depcheck/src/check.js

Lines 140 to 151 in 77fe0e2

parser === availableParsers.typescript
? // If this is a typescript file, importing foo would also use @types/foo, but
// only if @types/foo is already a specified dependency.
lodash(_dependencies)
.map((dependency) => {
const atTypesName = getAtTypesName(dependency);
return deps.includes(atTypesName)
? [dependency, atTypesName]
: [dependency];
})
.flatten()
.value()

I'd prefer to consider them used for all parsers (or at least have an option to), because they allow seeing the dependency types in the IDE while developing.

Code snippets

Where the dependency is used:

Any use of a dependency like `jest`

Where the dependency is listed in package.json:

// devDependencies
"jest": "x.y.z",
"@types/jest": "x.y.z",

Versions

  • node -v: v18.17.0
  • npm -v: 9.6.7
  • depcheck --version: 1.4.7

Extra info

Any extra info you want to include. Thank you for the bug report!

BONUS POINTS: If you wish to help us debug further, the depcheck --json option will show more information. Check here in the README for documentation on json output.

@alexeyr-ci alexeyr-ci added the bug label Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant