jsdoc: "Export default class" doesn't work as expected

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;

About this issue

  • Original URL
  • State: open
  • Created 9 years ago
  • Reactions: 9
  • Comments: 28 (2 by maintainers)

Commits related to this issue

Most upvoted comments

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

Also experiencing this issue in 3.5.5.

Me too, 3.5.5.

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

Still there in JSDoc 4.0.2

Same on 3.6.3

Facing this issue too. When creating a class extending another, it still generates a exports class

image

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.

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.

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’m seeing this with jsdoc 3.4.3

3.6.2 it doesn’t work yet 😦 I had to put it like

class MyClass {...}
export default MyClass;

@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 contact@9elements.com
 */

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:

screenshot 2016-02-22 07 45 58

Works fine with defining the class and exporting it in a second line

Same issue with export default function