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 

3 comments

1. npm i @types/yargs should solve the issue

2. but 

argv._[0]

is not a lodash usage.... It's argv object property. so the constant is indeed unused

 

1

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? 

0

>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

0

Please sign in to leave a comment.