JSDoc: arrow function parameters

I am trying to document my code using JSDoc (EcmaScript 2015, WebStorm 12 Build 144.3357.8).

I have an arrow function that I want to document. These are two examples. works (I get autocomplete):

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

But when I want to document arrow function in function forEachfor ex. autocomplete does not work (all below):

/** @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 been able to get this job?

Thanks in advance.

+4
source share
1 answer

Starting with the following EAP build, WebStorm will understand this:

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

See WEB-19280 for more details .

+5
source

Source: https://habr.com/ru/post/1626735/


All Articles