Code inspection not working probably
I'm having som issues with Webstorm. I'm using a package from npm called yargs however Webstorm cannot see that .command() is a method in the yargs package as you can see on line 9.
I'm also having another issue with it saying that a constant is unused which is being used on line 5.
Here are screenshots: https://imgur.com/a/qyQrs
Please sign in to leave a comment.
1. npm i @types/yargs should solve the issue
2. but
is not a lodash usage.... It's argv object property. so the constant is indeed unused
Hi Elena, thanks for your answer. Writing @types/yargs works:
const yargs = require('@types/yargs');However is this something I have to do in the future for other modules too if the same problem proceeds and what exactly does @types do to make it work?
>However is this something I have to do in the future for other modules too if the same problem proceeds
Yes.
>what exactly does @types do to make it work
It adds the library stubs (.d.ts) files to your project. Due to the dynamic nature of JavaScript, it is not always possible to resolve types during static code analysis, that's why adding library stubs where all types are defined explicitly helps to overcome the problem