简体   繁体   English

JSDoc:箭头函数参数

[英]JSDoc: arrow function params

I'm trying to document my code with JSDoc (EcmaScript 2015, WebStorm 12 Build 144.3357.8).我正在尝试使用 JSDoc(EcmaScript 2015,WebStorm 12 Build 144.3357.8)记录我的代码。

I have an arrow function which I want to document its parameters.我有一个箭头函数,我想记录它的参数。 This two examples work (I get auto-completion):这两个示例有效(我得到自动完成):

/** @param {Number} num1*/
var a = num1 => num1 * num1;
//------------------------------
/** @param {Number} num1*/
var a = num1 => {
    return num1 * num1;
};

But when I want to document an arrow function in forEach function, for example, the auto-completion isn't working (all of the below):但是,例如,当我想在forEach函数中记录箭头函数时,自动完成功能不起作用(以下所有内容):

/** @param {Number} num1*/
[].forEach(num1 => {
    return num1 * num1;
});
//------------------------------
/** @param {Number} num1*/
[].forEach(num1 => num1 * num1);
//------------------------------
[].forEach(/** @param {Number} num1*/num1 => num1 * num1);
//------------------------------
[].forEach(/** @param {Number} num1*/num1 => {
    return num1 * num1;
});

Has anyone managed to get this work?有没有人设法得到这项工作?

Starting from the next EAP build, WebStorm will understand this:从下一个 EAP 构建开始,WebStorm 将理解这一点:

[].forEach(/**Number*/num1 => {
    return num1 * num1;
});

Please look at WEB-19280 for details.详情请查看WEB-19280

You can use this format:您可以使用这种格式:

/**
 * @param {(prevState: ActionState) => ActionState} setActionState
 */
function f(setActionState) {
  // ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM