Skip to content

fix: expose TypeScript package subpaths#2818

Open
DivyamTalwar wants to merge 1 commit into
confident-ai:mainfrom
DivyamTalwar:fix/typescript-package-subpath-exports
Open

fix: expose TypeScript package subpaths#2818
DivyamTalwar wants to merge 1 commit into
confident-ai:mainfrom
DivyamTalwar:fix/typescript-package-subpath-exports

Conversation

@DivyamTalwar

@DivyamTalwar DivyamTalwar commented Jun 29, 2026

Copy link
Copy Markdown

Summary

The TypeScript package documents imports such as deepeval/metrics,
deepeval/models, deepeval/test-case, and deepeval/evaluate, but those
subpaths were not exposed through the package export map. The broken examples are
in typescript/src/metrics/README.md lines 22-23, 196, and 205, plus
typescript/src/models/README.md line 116. This adds the missing export and
typesVersions entries, preserves the existing camelCase deepeval/testCase
alias for compatibility, and reconciles the already-advertised
deepeval/annotation type subpath with a runtime export.

Changes

  • Add package exports for ./metrics, ./models, ./test-case, and
    ./evaluate.
  • Map the new subpaths to documented examples: metrics/model imports use
    ./metrics and ./models, test-case examples use kebab-case ./test-case,
    and evaluation examples use ./evaluate.
  • Add ./annotation to match the existing typesVersions.annotation entry.
  • Add matching TypeScript declaration paths in typesVersions.
  • Add a Jest smoke test that keeps package exports and typesVersions in sync,
    while also covering the currently documented subpaths and the existing
    ./testCase compatibility alias.
  • Add a build-backed package export smoke script and run it from TypeScript CI,
    even when the broader Jest suite fails earlier.
  • Limit the TypeScript workflow token to read-only repository contents, which is
    sufficient for checkout and package validation.

Why this matters

Users following the TypeScript examples should be able to import the documented
SDK entrypoints through the published package. TypeScript users also should not
see type metadata for a subpath that fails at runtime. The new tests make the
current package metadata and built export contract explicit so future export-map
regressions are caught early.

Tests

Commands run:

  • cd typescript && npm ci — passed
  • cd typescript && npm test -- package-exports.test.ts — passed
    (17 tests)
  • cd typescript && npm run test:package-exports — passed
  • cd typescript && npm run lint — passed with existing warnings in
    src/test-case/llm-test-case.ts and src/tracing/tracing.ts
  • cd typescript && npx prettier --check test/test-core/package-exports.test.ts test/test-core/package-exports-smoke.cjs
    — passed
  • cd typescript && npm run build — passed as part of
    npm run test:package-exports
  • Node require.resolve, require, dynamic import(), and emitted file checks
    for deepeval/metrics, deepeval/models, deepeval/test-case,
    deepeval/evaluate, deepeval/testCase, and safe package subpaths after build
    — passed through npm run test:package-exports
  • Packed-package consumer install check with npm pack and
    npm install --omit=dev — passed through npm run test:package-exports
  • Packed-package optional-peer check for deepeval/integrations/langchain
    passed; the smoke test verifies @langchain/core is absent in the production
    consumer install and that CJS/ESM imports fail with the expected missing-peer
    error
  • Temporary external TypeScript consumer compile check with a
    node_modules/deepeval symlink and imports from deepeval/annotation,
    deepeval/metrics, deepeval/models, deepeval/test-case,
    deepeval/evaluate, and deepeval/testCase — passed
  • git diff --check origin/main...HEAD — passed before commit

Also run:

  • cd typescript && npm test -- --runInBand — failed for pre-existing local
    environment/repo reasons: missing OPENAI_API_KEY, missing
    CONFIDENT_API_KEY, optional OpenAI Agents MCP dependency resolution, and an
    existing bad import in test/test-core/evaluate.test.ts. The
    evaluate.test.ts failure imports an internal source path
    (../../src/confident/evaluate) that is absent on main; it is separate from
    the deepeval/evaluate package subpath added here.
  • The full Jest suite remains red for pre-existing unrelated issues. This change
    runs export validation after successful dependency installation even when
    unrelated Jest failures occur earlier in the job, so the new package-export
    contract remains visible.
  • The existing TypeScript Prettier workflow remains red for pre-existing
    formatting drift in 66 source files. The PR-owned test files pass targeted
    Prettier checks and are no longer listed by that workflow.

Risk

Risk level: low

The change is additive package metadata and keeps the existing ./testCase
entrypoint intact. Rollback is straightforward: remove the added export/type
entries and the package export smoke test.

Issue

No existing issue. This was discovered during repository analysis.

Notes for maintainers

This intentionally supports only the subpaths already used by the TypeScript
examples, the existing compatibility alias, or an existing typesVersions public
type entry. Other namespace-style entrypoints can be considered separately if
maintainers want broader export-map symmetry.

@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

@DivyamTalwar is attempting to deploy a commit to the Confident AI Team on Vercel.

A member of the Team first needs to authorize it.

@DivyamTalwar DivyamTalwar force-pushed the fix/typescript-package-subpath-exports branch 2 times, most recently from 2d4e7a4 to 3875801 Compare June 29, 2026 17:12
@DivyamTalwar DivyamTalwar changed the title fix: expose documented TypeScript package subpaths fix: expose TypeScript package subpaths Jun 29, 2026
The TypeScript docs reference package subpaths that were not present in the
export map, so consumers following those examples could not rely on package-level
resolution for metrics, models, kebab-case test cases, or evaluate helpers. This
also aligns the existing annotation type subpath with a runtime export.

Constraint: Keep the change additive and limited to documented or already-advertised TypeScript entrypoints.
Rejected: Renaming or removing the existing testCase subpath | It may already be used by package consumers.
Confidence: high
Scope-risk: narrow
Directive: Keep future public TypeScript subpaths covered by package export smoke tests.
Tested: cd typescript && npm test -- package-exports.test.ts; cd typescript && npm run test:package-exports; cd typescript && npm run lint; temporary external TypeScript consumer compile check; git diff --check origin/main...HEAD
Not-tested: Full cd typescript && npm test -- --runInBand passes locally | existing suite requires missing OPENAI_API_KEY and CONFIDENT_API_KEY, has an optional OpenAI Agents MCP dependency resolution failure, and includes an existing bad import in test/test-core/evaluate.test.ts.
@DivyamTalwar DivyamTalwar force-pushed the fix/typescript-package-subpath-exports branch from 3875801 to 6f880f6 Compare June 29, 2026 17:16
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.

1 participant