Without exported event types, they must be duplicated in dependant code to correctly use the abstract Client class, which is needed when either a Producer or Consumer client could be the value of a class field. If no events are supplied to the Client class, then subscribing to event listeners doesn't work. When these types are duplicated in the dependant code and passed like _client?: Client<KafkaProducerEvents | KafkaConsumerEvents>, the event listener typings work correctly.
Exporting these types is the least effort to enable this usecase, otherwise requiring larger changes to how the abstract class is typed. One cannot say _client?: KafkaConsumer | Producer because then the event listener functions have conflicting types and cannot be used at all.
Without exported event types, they must be duplicated in dependant code to correctly use the abstract
Client
class, which is needed when either a Producer or Consumer client could be the value of a class field. If no events are supplied to theClient
class, then subscribing to event listeners doesn't work. When these types are duplicated in the dependant code and passed like_client?: Client<KafkaProducerEvents | KafkaConsumerEvents>
, the event listener typings work correctly.Exporting these types is the least effort to enable this usecase, otherwise requiring larger changes to how the abstract class is typed. One cannot say
_client?: KafkaConsumer | Producer
because then the event listener functions have conflicting types and cannot be used at all.