You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
loadPackageDefinition will load a gRPC package definition as a gRPC object hierarchy and in my E2E tests I need to define the types manually which is as you can guess it super tedious but important from the type-safety point of view. I do not like codes like this and usually you have a no any eslint rules somewhere in your project:
constproto=ProtoLoader.loadSync(join(__dirname,'../src/path-to-your/file.proto'),)asany;// Create Raw gRPC client objectconstprotoGRPC=GRPC.loadPackageDefinition(proto)asany;
So right now I am doing something like this as a workaround:
import{ChannelCredentials}from'@grpc/grpc-js';import{GrpcUserServiceClient,User,}from'../../../nestjs-client/src/assets/interfaces/user.interface';import{GrpcErrorResponse}from'./shared.type';interfaceGrpcUserService{new(url: string,credentials: ChannelCredentials,): GrpcUserServiceClient;}exportinterfaceLoadPackageDefinition{/**@description The name of our package which we wrote in our `user.proto` file. */user: {/**@description Comes from the name we gave to this service in our `user.proto` file. */GrpcUserService: GrpcUserService;};}// ...const{user: { GrpcUserService },}=loadPackageDefinition(packageDefinition,)asunknownasLoadPackageDefinition;
So my point is that this can be done in this lib. Right like where I am still using the type generated by this lib, e.g. here.
Do you think this can be added too? I mean right now my solution and any is prone to human errors and my types are hard to maintain over time (more protobuf files means more custom types and with each breaking change I have to go over all of them).
Appreciate your attention and replies 💮.
The text was updated successfully, but these errors were encountered:
loadPackageDefinition
will load a gRPC package definition as a gRPC object hierarchy and in my E2E tests I need to define the types manually which is as you can guess it super tedious but important from the type-safety point of view. I do not like codes like this and usually you have a noany
eslint rules somewhere in your project:— Ref.
So right now I am doing something like this as a workaround:
— Ref for the interface and here is the ref for the second part.
So my point is that this can be done in this lib. Right like where I am still using the type generated by this lib, e.g. here.
Do you think this can be added too? I mean right now my solution and any is prone to human errors and my types are hard to maintain over time (more protobuf files means more custom types and with each breaking change I have to go over all of them).
Appreciate your attention and replies 💮.
The text was updated successfully, but these errors were encountered: