jsdoc: JSDoc doesn't generete doc for ES6 functions like export const myFunction = ( ) => ........

Input code

When you declare an arrow function with an export like:

/**
 * Description.
 * @param {object} userInfo description
 */
export const setUserInfo = userInfo => ({ userInfo });

The generated documentation takes it like a constant while removing the export the documentation is generated fine.

JSDoc configuration

Default configuration

JSDoc debug output

No output

Expected behavior

should

Current behavior

expected

Your environment

Software Version
JSDoc 3.5.5
Node.js 8.9.4
npm 5.7.1
Operating system Windows 10

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 19
  • Comments: 17

Most upvoted comments

I was with the same problem and I didn’t find a solution. I have a utils file with multiple exported functions and the ‘export default’ solution didn’t be good in my case. I resolved that putting @method above the @params. Like this:

/**
 * @method
 * @param {String} str
 * @return {String}
*/

I don’t if it’s the best solution but I hope to help people with the same issue.

Facing same issue with JSDoc 3.6.4.

Adding /** @module moduleName */ at the top of the file doesn’t solve the issue. Only viable solution so far is using @function, which is a bit annoying.

I wonder if we are doing something wrong or if this is an actual bug.

I encounter the same kind of issue when you declare a class in the export section. ie:

export default class Embedded {
...
}

The best solution to address this, is to declare and export separately :

/**
 * Description.
 * @param {object} userInfo description
 */
const setUserInfo = userInfo => ({ userInfo });

export default setUserInfo;

and I got a documentation’s result close to what you wanted: capture d ecran 2018-05-29 a 15 31 45

Has there been any update on this? I’m trying to write a codebase in valid, standard ES2015 (standardized in 2015 I believe) and have typing support, but there doesn’t seem to be any tooling that supports it!

Exporting default doesn’t work, because one then can’t import specific symbols using the import syntax.

There is problem with the (arrow or regular) function expression exported (without tag @function, @func or @method).

Input code

/**
 * Foo
 */
export const foo = function () { };

/**
 * Bar
 */
export const bar = () => { };

/**
 * Baz
 * @function
 */
export const baz = function () { };

/**
 * Quz
 */
export function quz() { }

/**
 * Quux
 */
const quux = function () { };

JSDoc

Members

(static, constant) bar Bar

(static, constant) foo Foo

Methods

(static) baz() Baz

(static) quz() Quz

(inner) quux() Quux

Is adding the @function decorator still the best solution for this? Thoughts, all?

Yes the JS file