thesayyn / protoc-gen-ts

Compile protocol buffer messages to TypeScript.
MIT License
362 stars 75 forks source link

I need to generate file interface IUser {} #246

Open mjpcasey opened 11 months ago

mjpcasey commented 11 months ago

message User{ string userId = 1; string name = 2; string headImg = 3; } I need to generate file interface IUser {}

thesayyn commented 9 months ago

What do you mean you need to generate IUser?

plachta11b commented 9 months ago

I would expect this to be generated:

interface IUser {
  userId: string;
  name: string;
  headImg: string;
}

It would be handy to have a typescript object with the type acquired from the generator after converting gRPC PROTO models with the ToObject method.

thesayyn commented 9 months ago

This would make protoc-gen-ts generate more code, than it currently is. You can use typescript type inference for this.

Something like this would work;

type IUser = ReturnType<typeof User.prototype.toObject>