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

Typescript @types false positive #402

Closed
jerrygreen opened this issue Jul 24, 2019 · 3 comments
Closed

Typescript @types false positive #402

jerrygreen opened this issue Jul 24, 2019 · 3 comments

Comments

@jerrygreen
Copy link

jerrygreen commented Jul 24, 2019

Bug Description

All the @types/* libraries in devDependencies are counted as "unused".

More about @types repository: http://definitelytyped.org/

How it should work

depcheck should look into dependencies list and see if there's a library for that. For example:

I have added following packages to devDependencies:

  • @types/ramda
  • @types/react
  • @types/react-dom
  • @types/styled-components
  • @types/whatwg-fetch

And I have the following packages in my dependencies:

  • ramda
  • react
  • react-dom

depcheck should subtract these, and only count following packages as "unused":

  • @types/styled-components
  • @types/whatwg-fetch

Right now it counts all the 5 types packages as "unused"

Versions

  • node -v: 10.16.0
  • npm -v: 6.9.0
  • depcheck --version: 0.8.3
@KaboomFox
Copy link
Member

what is depcheck command you are running? How are the types packages imported?

@jerrygreen
Copy link
Author

@KaboomFox looks like you don’t understand the concept of DefinitelyTyped. Let me explain: it’s not used anywhere in the project code. It’s used by TypeScript server (for TypeScript compiler and IDEs). It’s needed so the libraries which don’t have types still may define its types from external packages.

So if I have library X without types, I may install @types/X - and types are there (no additional configuration, nor import is needed)

So if I have listed @types/Y but I don’t have listed Y package itself - then it should be considered “not using”

That was a long answer. Short answer to your question:

depcheck --skip-missing=true --ignores @types/*,typescript,husky,@now/next

P.S. I have to ignore @types/* because of that

@rumpl
Copy link
Member

rumpl commented Jul 31, 2019

This is a known issue (#163 ), we will get to it time permitting.

@rumpl rumpl closed this as completed Jul 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants