question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improved support for class fields and properties

See original GitHub issue

Hey there, I’ve got a class that uses the ES7 Class Fields and Properties proposal (as outlined https://github.com/jeffmo/es-class-fields-and-static-properties)

I’ve noticed that some of my properties get recognised and added to the documentation, but some do not. The ones that do get picked up are typically the uninitialised ones or ones with null, and the ones which are ignored are typically the ones with a default value assigned.

Example:

class Tracker {
    allowedLibraries = {
        'GTM': new GtmTracker(),
        'KISS': new KissTracker(),
        'Optimizely': new OptimizelyTracker()
    };

    eventQueueName = 'tracker_stuff';

    eventQueue = null;

    get queueLength() {
        return this.eventQueue.length;
    }
    // ... rest of code
}

Only two of these members appear in the docs:

screen shot 2016-06-17 at 1 42 41 pm

I’ve got the esdoc-es7-plugin installed and added to my config. Here are my installed versions:

"esdoc": "^0.4.7",
"esdoc-es7-plugin": "0.0.3",

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
typhonrtcommented, Jul 1, 2016

Yeah… That is a Babylon AST node & not ESTree… Well. It’s still possible to use the main ESDoc repo as you could get “sneaky” with a plugin. IE you could add babylon as a dependency for the plugin and in onHandleCode you could parse it and save the AST tree to consume and add extra tags during onHandleTags adding the ClassProperty node data to the variable / member data of the class.

In my fork the AST is waiting there to be handled in onHandleAST, but the above trick is so close to being the same. I’d really like to upstream the babylon fork I have though. The Babylon AST is essentially a superset more or less of ESTree syntax.

1reaction
typhonrtcommented, Jun 28, 2016

The esdoc-es7-plugin just ignores ES7 syntax, but is also out of date, so it doesn’t support anything related to ES7 as things go.

I can’t say this will help you, but I have a fork of ESDoc that supports Babylon for parsing with all Babylon plugins enabled by default here. It’s unpublished on NPM so you have to link to the Github repo. It would be interesting to see what the results would be with you example though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Faster initialization of instances with new class features
The initialization of class fields and private methods was much slower than the assignment of ordinary properties. The class field initializers ...
Read more >
c# - Properties vs. Fields: Need help grasping the uses of ...
I always use properties to get and set methods where possible. ... Using fields is usually practiced in private classes that is not...
Read more >
Public class fields - JavaScript - MDN Web Docs - Mozilla
Both static and instance public fields are writable, enumerable, and configurable properties. As such, unlike their private counterparts, they participate ...
Read more >
Add Support for Class Fields · Issue #2731 · google/closure ...
I wish to see this feature soon in closure compiler, having static fields helps a lot in class feature encapsulation. class A {...
Read more >
Backing Fields - EF Core
Backing fields allow EF to read and/or write to a field rather than a property. This can be useful when encapsulation in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found