Skip to content

fix: add types field to package.json for TypeScript support#581

Open
zxxj wants to merge 1 commit into
milvus-io:mainfrom
zxxj:fix/missing-types-field
Open

fix: add types field to package.json for TypeScript support#581
zxxj wants to merge 1 commit into
milvus-io:mainfrom
zxxj:fix/missing-types-field

Conversation

@zxxj

@zxxj zxxj commented Jun 26, 2026

Copy link
Copy Markdown

Problem

The package emits TypeScript declaration files via tsc --declaration during build (see dist/milvus/index.d.ts), but package.json is missing the types field. As a result:

  • TypeScript / VSCode cannot resolve types for @zilliz/milvus2-sdk-node
  • import { MilvusClient, MetricType } from "@zilliz/milvus2-sdk-node" works at runtime but provides no IntelliSense, no auto-completion, no type checking
  • Users have to manually write declare module shims or patch node_modules

Fix

Add a single line to package.json:

   "main": "dist/milvus",
+  "types": "dist/milvus/index.d.ts",
   "files": [
     "dist"
   ],

dist/milvus/index.d.ts is the entry-point declaration file already produced by the existing build script (tsc --declaration && node build.js), so no source code changes are required.

Verification

After this change, in any TypeScript project:

import { MilvusClient, MetricType, DataType, IndexType } from "@zilliz/milvus2-sdk-node";

const client = new MilvusClient({ address: "localhost:19530" });
//    ^? now shows the full MilvusClient type with all available methods

Editors will resolve the types automatically.

Notes

  • No runtime behavior change
  • No new files added
  • The build script already produces the referenced index.d.ts, so this is a metadata-only fix

The package emits TypeScript declaration files (dist/milvus/index.d.ts) via
`tsc --declaration` during build, but the package.json was missing the
`types` field. As a result, TypeScript editors could not resolve types
when importing from @zilliz/milvus2-sdk-node, even though the runtime
worked correctly.

This adds:
```
"types": "dist/milvus/index.d.ts"
```

Fixes the type resolution path so that `import { MilvusClient } from
"@zilliz/milvus2-sdk-node"` provides full IntelliSense and type-checking
in TypeScript projects.
@sre-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: zxxj

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sre-ci-robot

Copy link
Copy Markdown

Welcome @zxxj! It looks like this is your first PR to milvus-io/milvus-sdk-node 🎉

@zxxj

zxxj commented Jun 26, 2026

Copy link
Copy Markdown
Author

👋 The CI failure looks unrelated to this PR — it only adds a single types field to package.json (no runtime changes), and the failing tests are hitting real runtime issues:

  • Text Embedding Function APICollectionNotExists / Cannot read properties of null (reading 'fields') — collection isn't being created during test setup
  • http api by node-fetch v2FetchError: ... Premature close — looks like a Milvus container / network flake

These look like environment / flake issues rather than something this PR could have caused.

Could a maintainer with repo admin rights please re-run the failed job? 🙏

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants