简体   繁体   English

当PhpStorm猜测JavaScript函数的参数错误时,该如何纠正?

[英]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.

相关问题 如何将猜测次数添加到我的游戏中? Javascript - How do i add the number of guesses into my game? Javascript 我如何更改此代码以仅在找到目标后才打印猜测总数 - How do i change this code to only print the total number of guesses when it has found the target JavaScript Hangman游戏; 仅显示错误的猜测,当用户获胜时发出警报 - JavaScript Hangman Game; display only wrong guesses, alert when user wins 如何使用参数创建点函数? - How do I create dot functions with parameters? 使用iframe时,如何包含JavaScript函数? - When using an iframe how do I include javascript functions? 当系统时间错误时,如何在javascript中获取正确的时间? - when the time of system is wrong ,how can I get correct time in javascript? 如何使我自己的 JavaScript 函数具有必需的参数? - How do I make my own JavaScript functions have required parameters? 在JavaScript函数中使用php变量时,在PhpStorm中预期的表达式 - Expression expected in PhpStorm when using php variables in JavaScript functions 如何在JavaScript中更正此for循环? - How do I correct this for loop in javascript? 当使用JavaScript在a子手游戏中还剩下3个猜测(生命)时,如何显示提示? - How to display a hint when you have 3 guesses (lives) left in a hangman game using JavaScript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM