Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why JSDoc duplicates JSON records if I put ES6 "export" in front of an identifier?

Given following source code:

/** Comment */
const foo = {};

Generating JSON JSDoc documentation for it:

npx jsdoc -X foo.js

produces expected result:

[{
  "description": "Comment",
  "name": "foo",
  "kind": "constant",
  "scope": "global"
}]

But if i place export ES6 keyword in front of the identifier:

/** Comment */
export const foo = {};

the resulting JSON will contain two records for "foo"! One as previous and one "undocumented". Any hints why such strange behavior? Any way to fix it?

[{
  "description": "Comment",
  "name": "foo",
  "kind": "constant",
  "scope": "global"
},
{
  "undocumented": true,
  "name": "foo",
  "kind": "constant",
  "scope": "global"
}]
like image 401
grigoryvp Avatar asked Dec 07 '25 05:12

grigoryvp


1 Answers

According to the JSDoc documentation, you need to include a @module tag when using module exports.

You could do:

/** @module some/module */

/** Comment */
const foo = {};

or simply

/** @module */

/** Comment */
const foo = {};
like image 96
Marco Avatar answered Dec 09 '25 03:12

Marco



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!