Skip to content

Commit 1abd78e

Browse files
authored
Declare generated GrpcType inheritance
Generated interface ProtoGrpcType is in fact an extension of grpc.GrpcObject, but this inheritance wasn't declared until now. This forced users to cast `grpc.loadPackageDefinition(...): grpc.GrpcObject` first to `as unknown` and only then to `as {GeneratedGrpcType}`. With this fix users will be able to cast to `as {GeneratedGrpcType}` directly.
1 parent f621dc6 commit 1abd78e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/proto-loader/bin/proto-loader-gen-types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -760,12 +760,12 @@ function generateRootFile(formatter: TextFormatter, root: Protobuf.Root, options
760760
generateServiceImports(formatter, root, options);
761761
formatter.writeLine('');
762762

763-
formatter.writeLine('type SubtypeConstructor<Constructor extends new (...args: any) => any, Subtype> = {');
763+
formatter.writeLine('type SubtypeConstructor<Constructor extends new (...args: any) => any, Subtype> = grpc.ServiceClientConstructor & {');
764764
formatter.writeLine(' new(...args: ConstructorParameters<Constructor>): Subtype;');
765765
formatter.writeLine('};');
766766
formatter.writeLine('');
767767

768-
formatter.writeLine('export interface ProtoGrpcType {');
768+
formatter.writeLine('export interface ProtoGrpcType extends grpc.GrpcObject {');
769769
formatter.indent();
770770
for (const nested of root.nestedArray) {
771771
generateSingleLoadedDefinitionType(formatter, nested, options);

0 commit comments

Comments
 (0)