D
D
Dmitry Kim2016-04-22 09:57:56
JavaScript
Dmitry Kim, 2016-04-22 09:57:56

How to correctly describe a variable in Javascript in PhpStorm?

It used to be all the same, but now I decided to get confused. Let's say we use Yandex.maps, insert a call to the maps script

<script src="//api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>
, then next we write our script:
<script type="text/javascript">
$(function () {
  ymaps.ready(function () {
    // ......
  });
});

The IDE swears that it cannot determine "who is ymaps".
In php you can just write /* @var Array $ymaps */, for example, but what about in Javascript?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
P
Pavel Grishin, 2016-04-22
@Kstl

won't window.ymaps.ready(function (){}) work?

D
Denis Ineshin, 2016-04-22
@IonDen

Basically the same idea. You can create a reference.js file nearby (not included in the assembly) or something like that, and place this variable there. Or, in the project settings, add this variable as a global one.

F
Fetur, 2016-04-22
@Fetur

There is no sensible solution, when loading from api-maps.yandex.ru , you load everything just a module loader, which, if used, will be pulled up. Humble yourself.
How to load lib directly from IDE
Similar question on toaster
Maps API library chunks

K
Konstantin Kitmanov, 2016-04-22
@k12th

PHPStorm understands JSDoc .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question