When generating documentation for the code snippet below, the "Classes" menu on the right shows "exports" instead of "Car". Also, it shows "new exports()" instead of "new Car()" on its documentation page.
/**
* @property {number} id ID of the car.
*/
export default class Car {
}
The code below works fine, though:
/**
* @property {number} id ID of the car.
*/
class Car {
}
export default Car;
There were a number of issues with export default class in JSDoc 3.4.0, all of which should be fixed on GitHub master. JSDoc 3.4.1, which will be released soon, will include the fixes.
If you're still seeing issues on GitHub master, let me know so I can reopen this issue.
@hegemonic Still having that issue with the master branch:
/*
* Photo Editor SDK - photoeditorsdk.com
* Copyright (c) 2013-2015 9elements GmbH
*
* Released under Attribution-NonCommercial 3.0 Unported
* http://creativecommons.org/licenses/by-nc/3.0/
*
* For commercial use, please contact us at [email protected]
*/
import DisplayObject from './display-object'
/**
* A container for DisplayObject instances
* @class
* @alias Engine.Container
* @extends PhotoEditorSDK.Engine.DisplayObject
* @memberof PhotoEditorSDK
*/
export default class Container extends DisplayObject {
constructor (...args) {
super(...args)
}
/**
* The foo method.
*/
foo () {
}
}
Results in:

Works fine with defining the class and exporting it in a second line
@saschagehlich: Has this improved at all since you last posted? If not, a new issue may be in order.
I still have this problem.
Please note the version of jsdoc on npm is 3.4.0
If I have followed this thread correctly, this issue was fixed in jsdoc 3.4.1
Just updated to the latest development version, I still have this issue.
@hegemonic Can we reopen this issue since it is still not working.
Same issue with export default function
I'm seeing this with jsdoc 3.4.3
I've found jsdoc-export-default-interop plugin on npm that fixes the bug. Still, I hope it'll be fixed in the jsdoc3 without any side plugins.
I missed the fact that the examples are missing a @module tag, which JSDoc needs in order to know that it's parsing a module. Once you add that, everything works as expected (at least on GitHub master):
/** @module Car */
/**
* @property {number} id ID of the car.
*/
export default class Car {
}
The current GitHub master will be released soon as JSDoc 3.5.0.
Still the same issue with @3.5.4
/**
* Checks if the given object contains any null | undefined values
* If value inside of an object is an object, recursive check is done
* @param {Object} obj
* @return {boolean}
*/
export default function hasEmptyValues(obj) {
const keys = Object.keys(obj);
const nonEmpty = keys.filter((key) => {
const val = obj[key];
return !(val instanceof Array) && val instanceof Object ?
hasEmptyValues(val) : isEmptyValue(val);
});
return nonEmpty.length !== 0;
}
Builds to:
https://i.gyazo.com/7645bcde76062f5e92598d3a5c6ae900.png
The file has @module tag
Moving export default hasEmptyValues after function declaration seems to fix it
I have the same issue, also with the @module tag!( 3.5.5)
Same here.
Ping @hegemonic
Also experiencing this issue in 3.5.5.
Me too, 3.5.5.
This bug might also be related
https://github.com/jsdoc3/jsdoc/issues/1573
I was experiencing a similar issue with ES6 classes which extended another class. After looking into jsdoc-export-default-interop, it looked to me like the regex doesn't account for extends.
So I issued a PR last week which seems to fix my scenario, hopefully @nathanmarks will be happy to merge it. I'd be interested to learn if this impacts anyone else.
Can someone reopen this issue since it is not working with jsdoc 3.5.5?
3.6.2 it doesn't work yet :( I had to put it like
class MyClass {...}
export default MyClass;
Also having this issue in 3.6.2. Over multiple files, I'm exporting classes like so:
_foo.js_
/** A class which demonstrates how I'm using JSDoc */
export default class Foo {
/** Creates a new Foo. */
constructor () {
/** The baz of the Foo. */
this.baz = 9;
}
/** Makes the Foo beep. */
beep () {}
}
_bar.js_
/** Another class which demonstrates how I'm using JSDoc */
export default class Bar {
/** Creates a new Bar. */
constructor () {
/** The bez of the Bar. */
this.bez = 9;
}
/** Makes the Bar boop. */
boop () {}
}
Result:
Adding the @module workaround to a class gets it to show up, but it also appears as a module, and the constructor reads "new module:Foo()" which is an unintended side-effect. Further, if I name my module something else - /** @module Gob */, for example - the constructor now reads "new module:Gob()" even though the class is still called Foo.
It would be nice if JSDoc were able to parse the file as if it were a module without renaming the default export after the module - or is this intended behaviour?
Same on 3.6.3
Same issue here.
Had to move export default to the bottom
Ditto.
Just to be complete, I'm running latest:
master: npx jsdoc -v
JSDoc 3.6.6 (Sun, 20 Sep 2020 02:25:14 GMT)
Mainly I'd like to have a documentation update explaining the need to have the default export being a separate declaration. Then we can "fix" the problem if we see fit.
And boy, looking at the history of jsdoc, I appreciate the juggling act necessary to keep up:
3.0: May 2012; 1.0 2007; initally 1999 Netscape/Mozilla project Rhino!
My bet is that a lot of us are trying to balance jsDoc with vsCode. A lot of very subtle issues there when checkJs setting it set to true. jsDoc is now a bridge between TypeScript and JavaScript. Tough job!
Facing this issue too. When creating a class extending another, it still generates a exports class

Most helpful comment
@hegemonic Can we reopen this issue since it is still not working.