Wrong d.ts generation
krutoo opened this issue · 2 comments
krutoo commented
Hi, i have next proto file:
syntax = "proto3";
package some.service.proto;
service Offer {
rpc Calculate (Request) returns (Response);
}
message Request {
message Item {
int32 id = 1;
}
repeated Item items = 1;
}
message Response {
message Collection {
message Item {
string name = 1;
}
string name = 1;
repeated Item items = 2;
}
repeated Collection collections = 1;
}
after run deno run --allow-read https://deno.land/x/grpc_basic@0.4.3/gen/dts.ts ./index.proto > ./generated/index.d.ts
i have next d.ts file:
/* this code was generated by automated tool,
should not edit by hand */
export interface Offer {
Calculate(request: Request): Promise<Response>;
}
export interface Request {
items??: Item[];
}
export interface Item {
id?: number;
}
export interface Response {
collections??: Collection[];
}
export interface Collection {
name?: string;
items??: Item[];
}
export interface Item {
name?: string;
}
There are some syntax error (double question marks) and double export of different interfaces with same name.
What am I doing wrong?
prohazko2 commented
Hi
You're doing nothing wrong,
it's just generator that has some bugs
fixed some at https://deno.land/x/grpc_basic@0.4.4
prohazko2 commented
As for double export of nested Item
interface:
I'd like to leave it as it is because of simplistic nature of this lib.
And it's ok for typescript to have multiple merged interface declarations.
If it's not ok for your gRPC messaging - you can always write better typings manually.