Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KafkaJS typing mismatch #13077

Closed
4 of 15 tasks
Labels
needs triage This issue has not been looked into

Comments

@edeesis
Copy link
Contributor

edeesis commented Jan 22, 2024

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

@edeesis edeesis added the needs triage This issue has not been looked into label Jan 22, 2024
@kamilmysliwiec
Copy link
Member

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

peer dependency & strictLibCheck = true -> TS errors

Would you like to create a PR with updated types?

edeesis added a commit to edeesis/nest that referenced this issue Jan 23, 2024
@edeesis
Copy link
Contributor Author

edeesis commented Jan 23, 2024

@kamilmysliwiec Done, thanks!

@kamilmysliwiec
Copy link
Member

#13084

kamilmysliwiec added a commit that referenced this issue Feb 7, 2024
fix: #13077 KafkaJs typing consistency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment