@@ -454,6 +454,38 @@ function generateEnumInterface(formatter: TextFormatter, enumType: Protobuf.Enum
454
454
formatter . writeLine ( '}' ) ;
455
455
}
456
456
457
+ /**
458
+ * This is a list of methods that are exist in the generic Client class in the
459
+ * gRPC libraries. TypeScript has a problem with methods in subclasses with the
460
+ * same names as methods in the superclass, but with mismatched APIs. So, we
461
+ * avoid generating methods with these names in the service client interfaces.
462
+ * We always generate two service client methods per service method: one camel
463
+ * cased, and one with the original casing. So we will still generate one
464
+ * service client method for any conflicting name.
465
+ *
466
+ * Technically, at runtime conflicting name in the service client method
467
+ * actually shadows the original method, but TypeScript does not have a good
468
+ * way to represent that. So this change is not 100% accurate, but it gets the
469
+ * generated code to compile.
470
+ *
471
+ * This is just a list of the methods in the Client class definitions in
472
+
473
+ */
474
+ const CLIENT_RESERVED_METHOD_NAMES = new Set ( [
475
+ 'close' ,
476
+ 'getChannel' ,
477
+ 'waitForReady' ,
478
+ 'makeUnaryRequest' ,
479
+ 'makeClientStreamRequest' ,
480
+ 'makeServerStreamRequest' ,
481
+ 'makeBidiStreamRequest' ,
482
+ 'resolveCallInterceptors' ,
483
+ /* These methods are private, but TypeScript is not happy with overriding even
484
+ * private methods with mismatched APIs. */
485
+ 'checkOptionalUnaryResponseArguments' ,
486
+ 'checkMetadataAndOptions'
487
+ ] ) ;
488
+
457
489
function generateServiceClientInterface ( formatter : TextFormatter , serviceType : Protobuf . Service , options : GeneratorOptions ) {
458
490
if ( options . includeComments ) {
459
491
formatComment ( formatter , serviceType . comment ) ;
@@ -463,6 +495,9 @@ function generateServiceClientInterface(formatter: TextFormatter, serviceType: P
463
495
for ( const methodName of Object . keys ( serviceType . methods ) . sort ( ) ) {
464
496
const method = serviceType . methods [ methodName ] ;
465
497
for ( const name of [ methodName , camelCase ( methodName ) ] ) {
498
+ if ( CLIENT_RESERVED_METHOD_NAMES . has ( name ) ) {
499
+ continue ;
500
+ }
466
501
if ( options . includeComments ) {
467
502
formatComment ( formatter , method . comment ) ;
468
503
}
0 commit comments