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

Typescript class decorators and a static factory method creates a class with _1 suffix #105

Open
captnCC opened this issue Sep 21, 2020 · 3 comments

Comments

@captnCC
Copy link

captnCC commented Sep 21, 2020

When writing a class that has a static factory method which creates a new instance of the class itself, the class will be suffixed with _1 in the created docs.
Sample:

/**
 * MyClass
 */
@myDecorator()
class MyClass {
    static factory(){
        return new MyClass()
    }
    constructor(){}
}

The JsDoc than contains a Class MyClass_1 that misses the class description.

@wojtek-krysiak
Copy link
Contributor

this is a bug. Before passing the code to jsdoc we transpile it with ts. and it changes decorators.

not sure. but can you first create class with jsdoc and then add decorator before exporting the file? (not sure this in possible in ts)?

@captnCC
Copy link
Author

captnCC commented Sep 22, 2020

The decorator has to be before the class itself. The order between the JSDoc Comment and the decorator should be irrelevant.

I played bit around and removed the decorator with a regex before passing the source to the ts compiler. That worked but I don't know if it is a feasible option to create a regex that catches all decorators but ignores the JSDoc annotations.

@wojtek-krysiak
Copy link
Contributor

wojtek-krysiak commented Sep 22, 2020

tbh, the current way how better docs works is not scallable. In the long run we will have to get rid of jsdoc and parse everything on our own. But this is a huge project (week of work) and not sure we can invest on this right now.

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

2 participants