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

Why generated TypeScript definitions service method return type didn't contain Promise type? #770

Closed
LaysDragon opened this issue Apr 21, 2017 · 3 comments

Comments

@LaysDragon
Copy link

protobuf.js version: latest in master

protofile:
service ClientService {
    rpc Search (result) returns (result)
    {
        option (local_method_id) = 1;
    }
    rpc echo (answer) returns (answer)
    {
        option (local_method_id) = 2;
    }
}

expected:

public echo(request: com.Protocol.Ianswer, callback?: ClientService_echo_Callback): void|Promise<com.Protocol.answer>;

actual

public echo(request: com.Protocol.Ianswer, callback: ClientService_echo_Callback): void;
@dcodeIO
Copy link
Member

dcodeIO commented Apr 21, 2017

Seems JSDoc has stopped documenting because, well, I didn't add enough bullshit annotations and workarounds with undocumented side effects to the generated code's comments. Did that now.

@LaysDragon
Copy link
Author

LaysDragon commented Apr 21, 2017

still not work ;(
It looks like jsdoc's problem?
look here
image

The memberof property not same cause second definitions for promise used is never be found by 'getChildrenOf()'
image
There should find 5 methods but only 3.
value should be 'com.Protocol.ClientService' not 'ClientService'
maybe can fix by add @memberof tag

@LaysDragon
Copy link
Author

LaysDragon commented Apr 21, 2017

I fix the problem by replace the code:

 pushComment([
            method.comment || "Calls " + method.name + ".",
            "@function " + escapeName(service.name) + "#" + lcName,
            "@param {" + exportName(method.resolvedRequestType, !config.forceMessage) + "} request " + method.resolvedRequestType.name + " message or plain object",
            "@returns {Promise<" + exportName(method.resolvedResponseType) + ">} Promise",
            "@variation 2"
        ]);

reaplace escapeName(service.name) to escapeName(service.toString().split(' ')[1].substr(1))
I'll make a pull request later.

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

Successfully merging a pull request may close this issue.

2 participants