Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES6 class property lost when in module #1182

Closed
pabigot opened this issue Mar 23, 2016 · 4 comments
Closed

ES6 class property lost when in module #1182

pabigot opened this issue Mar 23, 2016 · 4 comments
Labels
Milestone

Comments

@pabigot
Copy link

pabigot commented Mar 23, 2016

In the example below the instance property p is documented in the ES5 "class" but is missing from the documentation for the ES6 class. If the @module tag is removed from the header it appears in both variants.

This may be related to the bug noted in #1134.

/**
 * @module
 */
'use strict';

/**
 * Test ES5 constructor handling.
 *
 * @param {String} p initializes {@link ES5#p}.
 *
 * @constructor
 */
function ES5(p) {
  /**
   * Some property.
   * @type {String}
   */
  this.p = p;
}

/**
 * Test ES6 constructor handling.
 */
class ES6 {
  /**
   * Create an ES6
   * @param {String} p initializes {@link ES6#p}.
   */
  constructor(p) {
    /**
     * Some property.
     * @type {String}
     */
    this.p = p;
  }
}
@pabigot
Copy link
Author

pabigot commented Mar 28, 2016

Looking into it I see that doclets are being generated for both styles but with different longnames and properties.

With the ES5 syntax it's

  • module:mymod~ES5 kind=class scope=inner
  • module:mymod~ES5#p kind=member scope=instance

With the ES6 syntax it's:

  • module:mymod~ES6 kind=class scope=inner
  • module:mymod~ES6.ES6 kind=class scope=static
  • module:mymod~ES6.ES6#p kind=member scope=instance

If this namepath difference is not intentional I suspect the problem is in findSymbolMemberOf() directly or in Parser.resolveThis() when invoked from findSymbolMemberof().

Any suggestions on the best path to a fix?

@svenkreiss
Copy link

I see the same problem.
@pabigot Do you have a fix?

@bennycode
Copy link

Any update on this one? Because it blocks: englercj/tsd-jsdoc#21

tsd-jsdoc is a tool to generate TypeScript definitions from JSDoc comments (pretty cool!), but when ES6 class properties are lost, then they are also lost in the definition file. 😢

@hegemonic
Copy link
Contributor

Fixed on master. The fix will be included in JSDoc 3.5.0.

lheberlie added a commit to bsvensson/jsdoc that referenced this issue Aug 15, 2017
3.5.0

* tag '3.5.0': (97 commits)
  3.5.0
  bump revision; start 3.6.0-dev
  update 3.5.0 changelog
  3.5.0 changelog
  reformat changelog
  add yields tag (jsdoc#1388)
  resolve the path to the JS config file before requiring it (jsdoc#1386)
  support namespaces that are also functions (jsdoc#955)
  add hideconstructor tag (jsdoc#952)
  add package tag (jsdoc#962)
  autodetect default and repeatable parameters when a function is assigned to a variable (jsdoc#1054)
  correctly document constructors and instance properties of ES2015 classes (jsdoc#1182)
  add sourceType config option
  fix crash when the author tag is empty (jsdoc#1289)
  add recurseDepth config option (jsdoc#1340)
  support bigint
  support import.meta
  support optional chaining
  support numeric separators
  support dynamic import
  ...

# Conflicts:
#	.eslintrc
#	README.md
#	lib/jsdoc/fs.js
#	lib/jsdoc/opts/args.js
#	lib/jsdoc/src/astbuilder.js
#	lib/jsdoc/src/astnode.js
#	lib/jsdoc/src/handlers.js
#	lib/jsdoc/src/parser.js
#	lib/jsdoc/src/visitor.js
#	lib/jsdoc/src/walker.js
#	lib/jsdoc/tag/dictionary/definitions.js
#	lib/jsdoc/tag/validator.js
#	lib/jsdoc/util/markdown.js
#	lib/jsdoc/util/templateHelper.js
#	package.json
#	templates/default/static/styles/jsdoc-default.css
#	templates/haruki/publish.js
#	test/spec-collection.js
#	test/specs/documentation/defaultparams.js
#	test/specs/documentation/restparams.js
#	test/specs/jsdoc/src/astnode.js
#	test/specs/jsdoc/util/templateHelper.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants