Skip to content

KafkaJS typing mismatch #13077

@edeesis

Description

@edeesis

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

image

Minimum reproduction code

https://github.com/edeesis/kafkajs-nest

Steps to reproduce

Attempt to re-use the KafkaJS KafkaConfig typing in the Nest MicroserviceOptions. You'll get a typescript error as screenshotted above.

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { KafkaConfig } from 'kafkajs';
import { MicroserviceOptions, Transport } from '@nestjs/microservices';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  const config: KafkaConfig = {
    clientId: 'client-id',
    brokers: process.env.KAFKA_BROKERS.split(','),
  };
  await app.connectMicroservice<MicroserviceOptions>({
    transport: Transport.KAFKA,
    options: {
      client: config,
    },
  });
  await app.listen(3000);
}

Expected behavior

Typings should match.

I'm also curious why there's a need for separate typings, rather than using the typings exported from kafkajs.

Package

  • I don't know. Or some 3rd-party package
  • @nestjs/common
  • @nestjs/core
  • @nestjs/microservices
  • @nestjs/platform-express
  • @nestjs/platform-fastify
  • @nestjs/platform-socket.io
  • @nestjs/platform-ws
  • @nestjs/testing
  • @nestjs/websockets
  • Other (see below)

Other package

No response

NestJS version

10.x

Packages versions

{
  "dependencies": {
    "@nestjs/common": "^10.3.0",
    "@nestjs/config": "^3.1.1",
    "@nestjs/core": "^10.3.0",,
    "@nestjs/microservices": "^10.3.0",
    "kafkajs": "^2.2.4",
  }
}

Change was done in kafkajs 2.2.1

Node.js version

20.x

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue has not been looked into

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions