hufeng commented on issue #302: URL: https://github.com/apache/dubbo-js/issues/302#issuecomment-1321755361
@creasy2010 东哥,这个地方, ```typescript // generate request type export interface HelloRequest { name:string } // generate response type export interface HelloReply { message: string } // generate service interface export interface IHelloService { sayHello(helloRequest: HelloRequest): Promise<HelloReply> } // generate dubbo client stub service export const HelloService = dubbo.newClientStubService<IHelloService>({ name: 'HelloService', methods: { sayHello(helloRequest) { return { args: [HelloRequest], //... maybe other information } }, }) dubboClient.addStubServices({helloSerivce: HelloService}) ``` 这个地方我的想法 对newClientStubService方法设计,需要考虑点: - 对于invoke来说,他需要的是数据结构本身,其实这个api类似于dubbojs2中的proxyService啥也没有做就是返回这个数据结构 - 之前设计proxyService的逻辑是类型约束,如果是类型约束也可以不需要函数来做,直接一个interface也行 - 为了类型的推导我们覆盖了 dubbo.newClientStubService<IHelloService> 返回值类型,这样不好,导致代码内部拿不到原始类型 这个方法可以约束类型,但不应该覆盖返回类型,返回类型单独export出来 ```typescript // generate request type export interface HelloRequest { name:string } // generate response type export interface HelloReply { message: string } // generate service interface export interface IHelloService { sayHello(helloRequest: HelloRequest): Promise<HelloReply> } // generate dubbo client stub service export const HelloService = dubbo.newClientStubService({ name: 'HelloService', methods: { sayHello(helloRequest) { return { args: [HelloRequest], //... maybe other information } }, }) dubboClient.addStubServices({helloSerivce: HelloService}) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For additional commands, e-mail: notifications-h...@dubbo.apache.org