Skip to content

Commit 2e7774c

Browse files
milindldavidkhala
andauthored
Fix type definition issues in the constructors (#321)
* Update kafkajs.d.ts constructor config mark as optional properly * Add type definition fixes * Add PR number --------- Co-authored-by: David Liu <[email protected]>
1 parent 1286dc0 commit 2e7774c

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ v1.3.1 is a maintenance release. It is supported for all usage.
44

55
## Fixes
66

7-
1. Avoid a race condition that causes 100% usage of a CPU core when
7+
1. Avoid a race condition that causes 100% usage of a CPU core when
88
consuming with `partitionsConsumedConcurrently > 1` and all messages
99
are consumed (#300)
10+
2. Fix type definition for `Kafka()` constructor and for passing topic configurations
11+
to the `producer()` and `consumer()` in the promisified API (@davidkhala, #297, #321).
1012

1113

1214
# confluent-kafka-javascript v1.3.0

types/kafkajs.d.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { ConsumerGlobalConfig, GlobalConfig, ProducerGlobalConfig } from './config'
1+
import {
2+
ConsumerGlobalConfig,
3+
ConsumerTopicConfig,
4+
GlobalConfig,
5+
ProducerGlobalConfig,
6+
ProducerTopicConfig } from './config'
27
import {
38
ConsumerGroupStates,
49
GroupOverview,
@@ -94,7 +99,7 @@ export interface CommonConstructorConfig extends GlobalConfig {
9499
}
95100

96101
export class Kafka {
97-
constructor(config: CommonConstructorConfig)
102+
constructor(config?: CommonConstructorConfig)
98103
producer(config?: ProducerConstructorConfig): Producer
99104
consumer(config: ConsumerConstructorConfig): Consumer
100105
admin(config?: AdminConstructorConfig): Admin
@@ -131,7 +136,9 @@ export interface ProducerConfig {
131136
logger?: Logger,
132137
}
133138

134-
export interface ProducerConstructorConfig extends ProducerGlobalConfig {
139+
type ProducerGlobalAndTopicConfig = ProducerGlobalConfig & ProducerTopicConfig;
140+
141+
export interface ProducerConstructorConfig extends ProducerGlobalAndTopicConfig {
135142
kafkaJS?: ProducerConfig;
136143
}
137144

@@ -235,7 +242,9 @@ export interface ConsumerConfig {
235242
partitionAssignors?: PartitionAssignors[],
236243
}
237244

238-
export interface ConsumerConstructorConfig extends ConsumerGlobalConfig {
245+
export type ConsumerGlobalAndTopicConfig = ConsumerGlobalConfig & ConsumerTopicConfig;
246+
247+
export interface ConsumerConstructorConfig extends ConsumerGlobalAndTopicConfig {
239248
kafkaJS?: ConsumerConfig;
240249
}
241250

0 commit comments

Comments
 (0)