[英]How do I correct PhpStorm when it guesses the wrong parameters for JavaScript functions?
Looking around this seems to be the closest it comes to being an answer to my problem. 环顾这似乎是谈到作为一个回答我的问题最接近的一次。 However it causes other issues...
但是,这会导致其他问题...
This is my situation: 这是我的情况:
$element.insertBefore($container);
This line has a warning that insertBefore
has an “ Invalid number of arguments, expected 2 ” 此行发出警告,提示
insertBefore
具有“ 无效数量的参数,预期为2 ”
/** @type {function(target)} */
$element.insertBefore;
$element.insertBefore($container);
These three lines have a warning, but for a different reason. 这三行发出警告,但原因不同。 The third line no longer has any warning about an invalid number of arguments;
第三行不再警告有关无效数量的参数; however the second line is now concerned that the “ Expression statement is not assignment or call ”.
但是,第二行现在担心“ 表达式语句不是赋值或调用 ”。
I tried a number of other configurations however none of them seem to affect the first warning in any way… but they don't create new warnings. 我尝试了许多其他配置,但是它们似乎都没有以任何方式影响第一个警告……但是它们不会创建新的警告。 Some of these variations are as follows:
其中一些变化如下:
/** @type {function(target)} */
/* $element.insertBefore; */
$element.insertBefore($container);
— -
/** @type {function(target)}
$element.insertBefore; */
$element.insertBefore($container);
— -
/** @type {function(target)} */
$element.insertBefore($container);
I was just wondering if anyone could give me pointers on what I'm doing wrong or if this warning is just an irreversible mistake for the system right now. 我只是想知道是否有人可以向我指出我在做错什么,或者此警告是否只是当前系统的不可逆错误。
PS This is actually JavaScript code… I just have a habit of prefacing variables that are instances of jQuery objects with a dollar sign. PS这实际上是JavaScript代码…我只是习惯对变量加前缀,这些变量是带有美元符号的jQuery对象的实例。 This means that the above calls to
insertBefore
are calls to the jQuery function not the vanilla JavaScript function. 这意味着上述对
insertBefore
的调用是对jQuery函数的调用,而不是普通的JavaScript函数。
似乎insertBefore()确实需要2个参数: https : //www.w3schools.com/jsref/met_node_insertbefore.asp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.