Blizzard / node-rdkafka

Node.js bindings for librdkafka
MIT License
2.08k stars 391 forks source link

Export event types for use with abstract Client class #1083

Closed Tapppi closed 4 days ago

Tapppi commented 3 weeks ago

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.