Search code examples
javascriptangularjsintellij-ideaideecmascript-5

'Unresolved variable' about some variable used just one line above (PHPStorm 2018.2.5)


I'm struggling with my IDE with a simple code. I'm running under Angular 1.4, ES 5.1.

function myFunction() {
    var vm = this;
    vm.listResults = null;

    SomeService.someFunction()
        .then(function (result) {
            vm.listResults = result;

            if (vm.listResults.length > 0) {
                vm.selectCity(vm.listResults[0]);
            }
        });
}

vm.selectCity = function (city) {};

The last if statement throws a warning and declares the vm.listResults variable unresolved. Same for the call to selectCity and its parameter. I can't CTRL+CLICK on those three and I don't really understand why.

What do I have to enabled in order to link this properly ?

Under Languages & Frameworks > Javascript > Libraries I have angular-DefinitelyTyped, HTML & Node.js Core checked and that's all.

And yes, I could disable the warnings but I'd rather not to, I really want to understand.

Thanks a lot for your help :)


Solution

  • So basically as I just replied, my project is like a big library commonly used by many of our other projects (common controllers / directives / services / filters...). It doesn't include angularjs in its package.json because this lib is just imported into projects that already load it, so I guess that's why it didn't work.

    Adding this same library into its own libraries just solved my problems :)