Skip to content

fix(package.json): correct broken "types" path so TS consumers get types#484

Open
Dvir Arad (dvirarad) wants to merge 1 commit into
confluentinc:masterfrom
dvirarad:fix/package-json-types-path
Open

fix(package.json): correct broken "types" path so TS consumers get types#484
Dvir Arad (dvirarad) wants to merge 1 commit into
confluentinc:masterfrom
dvirarad:fix/package-json-types-path

Conversation

@dvirarad
Copy link
Copy Markdown

Summary

Fixes #403.

package.json advertises

"types": "types/index.d.ts"

but that file does not exist in the published package or in the repo. The actual type entry is the top-level index.d.ts, which re-exports the per-module declarations:

// index.d.ts (repo root)
export * from './types/rdkafka';
export * as RdKafka from './types/rdkafka';
export * as KafkaJS from './types/kafkajs';

Impact

With the current types path pointing at a non-existent file, TypeScript consumers of @confluentinc/kafka-javascript get no types at all when they import { ... } from '@confluentinc/kafka-javascript' — they see any everywhere. Workarounds in the wild include "paths" shims or direct deep imports from node_modules/.../types/rdkafka, neither of which should be necessary. Maintainer Pratyush Ranjan (@PratRanj07) acknowledged the bug in #403 (internal ticket 4253).

Verification

On master today (2026-05-11):

curl -sI https://raw.githubusercontent.com/confluentinc/confluent-kafka-javascript/master/types/index.d.ts  → 404
curl -sI https://raw.githubusercontent.com/confluentinc/confluent-kafka-javascript/master/index.d.ts        → 200

The types/ directory exists and contains config.d.ts, errors.d.ts, kafkajs.d.ts, rdkafka.d.ts, etc., but there is no index.d.ts inside it. The only index.d.ts in the repo is at the root.

Fix

One-line change in package.json:

-  "types": "types/index.d.ts",
+  "types": "index.d.ts",

index.d.ts is already shipped (it lives at the repo root and is not in .gitignore / files-excluded), so no other changes are needed. After this fix, tsc resolves @confluentinc/kafka-javascript to the existing root index.d.ts and downstream users get the full RdKafka / KafkaJS types.

Test plan

  • curl confirms index.d.ts exists and types/index.d.ts 404s on master
  • npm pack --dry-run (locally) shows index.d.ts is included in the tarball alongside types/*.d.ts
  • test:types script (tsc -p .) still passes (no source change — only the manifest pointer moved)
  • CI green

Happy to add a small consumer smoke-test (tsc --noEmit against a tiny import { KafkaJS } from '@confluentinc/kafka-javascript' stub) if maintainers want a regression guard.

The "types" field pointed to types/index.d.ts which does not exist; the root
index.d.ts is the real types entry (re-exports types/rdkafka and types/kafkajs).
This means TypeScript users currently get no types from the package.

Closes confluentinc#403
Copilot AI review requested due to automatic review settings May 11, 2026 07:55
@dvirarad Dvir Arad (dvirarad) requested review from a team as code owners May 11, 2026 07:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes TypeScript type resolution for @confluentinc/kafka-javascript by correcting the package.json types entry to point at the existing root index.d.ts (instead of the non-existent types/index.d.ts), addressing #403.

Changes:

  • Update package.json "types" field from types/index.d.ts to index.d.ts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing Type Definition File Referenced in package.json for @confluentinc/kafka-javascript@1.6.0

2 participants