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

Support @property on classes #418

Open
mattberkowitz opened this issue Apr 26, 2017 · 3 comments
Open

Support @property on classes #418

mattberkowitz opened this issue Apr 26, 2017 · 3 comments

Comments

@mattberkowitz
Copy link

Short summary of your issue

I would like to be able to declare class properties as part of a class definition rather than using @type when initializing them setting them in a constructor. The primary driver for this is declaring properties while using Immutable js.

/**
 * Represents an article
 * @extends {Immutable.Record}
 * @property {string} id - Unique Identifier for Content
 * @property {?string} headline - Headline for the article
 * @property {?string} body - Article body
 */
class Article extends Record({
  id: null,
  headline: '',
  body: ''
}) {
  get lede() { return this.body.split('\n')[0]; }
}

I'm able to get the display how I want with a plugin which seems very hacky:

exports.onHandleTag = function onHandleTag(ev) {
  ev.data.tag.forEach((t) => {
    if (t.kind === 'class') {
      t.properties.forEach((prop) => {
        ev.data.tag.push({
          __docId__: ev.data.tag[ev.data.tag.length - 1].__docId__   1,
          kind: 'member',
          name: prop.name,
          memberof: t.longname,
          static: false,
          longname: t.longname   '#'   prop.name,
          access: null,
          description: prop.description,
          undocument: false,
          unknown: [],
          type: {
            types: prop.types
          }
        })
      })
    }
  })
}

If you agree with this proposal, I'm happy to take a stab at a PR.

@loopmode
Copy link

loopmode commented May 29, 2017

Having the same issue. Proposed syntax should do fine. 1

@jwhitmarsh
Copy link

Any luck with this @mattberkowitz ?

@SamiSammour
Copy link

It's frustrating that I can't do such thing.. and now there's no such thing as onHandleTag so I'm stuck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants