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

Anonymous class #13

azu opened this issue Jun 20, 2015 · 3 comments

Anonymous class #13

azu opened this issue Jun 20, 2015 · 3 comments


Copy link

@azu azu commented Jun 20, 2015

ES6 Classes allow to anonymous.

ClassDeclaration[Yield, Default] :
    class BindingIdentifier[?Yield] ClassTail[?Yield]
    [+Default] class ClassTail[?Yield] // <= export default class { }

ClassTail[Yield] :
    ClassHeritage[?Yield]opt { ClassBody[?Yield]opt }

esdoc fail to parse anonymous class and throw error.

I'v create example repository : azu/esdoc-no-class-name-issue

// anonymous class
export default class {
        this.description = "this is example class";

parse error:

$ npm run doc

> esdoc-no-class-name-issue@1.0.0 doc /Users/azu/.ghq/
> esdoc -c esdoc.json

            throw _iteratorError5;
TypeError: Cannot read property 'name' of null
    at (/Users/azu/.ghq/
    at ClassDoc._apply (/Users/azu/.ghq/
    at ClassDoc._apply (/Users/azu/.ghq/
    at ClassDoc.AbstractDoc (/Users/azu/.ghq/
    at new ClassDoc (/Users/azu/.ghq/
    at DocFactory._createDoc (/Users/azu/.ghq/
    at DocFactory._traverseComments (/Users/azu/.ghq/
    at DocFactory.push (/Users/azu/.ghq/
    at Controller.<anonymous> (/Users/azu/.ghq/
    at Controller.enter (/Users/azu/.ghq/

I suggest that esdoc throw warning instead of error.

Copy link

@h13i32maru h13i32maru commented Jun 21, 2015

@azu Thank you for reporting this issue! Sorry, I did not know the specifications...

  • idea 1: ESDoc throws warning and not output document of an anonymous class.
  • idea 2: ESDoc treats all anonymous classes as export default class Anonymous {}.
  • idea 3: ESDoc guesses a name of an anonymous class from the file name.
    • e.g. with your repository, the anonymous class as export default class ExampleClass {}

I think that idea 3 is good. What do you think about ideas?

Copy link

@azu azu commented Jun 21, 2015

I vote for idea 3 👍
If you implement idea 3, need to validate the file name as valid JavaScript variable names.

h13i32maru added a commit that referenced this issue Jun 30, 2015
Copy link

@h13i32maru h13i32maru commented Jun 30, 2015

I fixed this issue. I will release it in next version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants