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 Plugin] - Spread operator not handled #66

Open
qbodart opened this issue Jul 13, 2018 · 3 comments
Open

[Typescript Plugin] - Spread operator not handled #66

qbodart opened this issue Jul 13, 2018 · 3 comments

Comments

@qbodart
Copy link

qbodart commented Jul 13, 2018

I have a function in typescript that returns a promise. The spread operator is used to merge properties of two objects. ESDoc fails on that line and runs smoothly when I cut it.

return new Promise((resolve, reject) => {
    this.service.findByUserId(userId, relationsUser)
    .then(async (user: User) => {
        if (!user) throw new NotFoundException('User does not exist');
        const authUser = await this.service.getAuth0UserProfile(user.userId);
        resolve({ ...authUser, ...user}); <-- Does not work
    })
    .catch(reason => reject(reason));
});

Any idea how to solve this? Thanks!

@ziuniecki
Copy link

ziuniecki commented Aug 27, 2018

I have the same problem :/ any ideas?

OK I found how to solve this problem. I installed this plugin:
https://github.com/esdoc/esdoc-plugins/tree/master/esdoc-ecmascript-proposal-plugin

and now my .esdoc.json is:

{
    "source": "./src",
    "destination": "./docs",
    "includes": [
        "\\.ts$"
    ],
    "excludes": [
        "\\.config\\.ts$"
    ],
    "plugins": [
        {
            "name": "esdoc-ecmascript-proposal-plugin",
            "option": {
                "classProperties": true,
                "objectRestSpread": true,
                "doExpressions": true,
                "functionBind": true,
                "functionSent": true,
                "asyncGenerators": true,
                "decorators": true,
                "exportExtensions": true,
                "dynamicImport": true
            }
        },
        {
            "name": "esdoc-typescript-plugin",
            "option": {
                "enable": true
            }
        },
        {
            "name": "esdoc-standard-plugin"
        }
    ]
}

And no problem with spread operators :)

@qbodart
Copy link
Author

qbodart commented Aug 28, 2018

I solved it by using Object.assign().

@bbugh
Copy link

bbugh commented Nov 24, 2018

@ziunio workaround didn't work for me. In my case, I have functions with spread parameters with Types that esdoc is resulting in "undefined". This function:

thing (...thingConstructors: ThingConstructor<Thing>[]): number[] {

generates this documentation:

public thing(thingConstructors: undefined): *

Whether I use that plugin or not.

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

3 participants