Skip to content

fix(types): declare types condition in exports for ESM consumers#2815

Open
mattconcord wants to merge 1 commit into
openapi-ts:mainfrom
mattconcord:fix/types-declare-esm-entry
Open

fix(types): declare types condition in exports for ESM consumers#2815
mattconcord wants to merge 1 commit into
openapi-ts:mainfrom
mattconcord:fix/types-declare-esm-entry

Conversation

@mattconcord
Copy link
Copy Markdown

Problem

Under modern TypeScript / tsgo (Go-rewritten compiler), packages with "type": "module" and no explicit exports.types condition fail to resolve types because the legacy sibling-.d.ts fallback is being removed.

Both openapi-fetch and openapi-typescript currently have no "types" condition in their exports map, causing TypeScript consumers to potentially see type resolution issues as tsgo tightens its module resolution.

Fix

One line added to each package's package.json:

  • packages/openapi-fetch/package.json: "types": "./dist/index.d.ts" as first condition in exports."."
  • packages/openapi-typescript/package.json: "types": "./dist/index.d.ts" as first condition in exports."."

Both point at the .d.ts declaration files the packages already ship in dist/. The "types" condition must come first (TypeScript's resolver reads conditions in declared order).

Impact

  • No behavioral change — pure manifest fix, two lines
  • TypeScript / tsgo consumers can now resolve types deterministically
  • ESM consumers (both import and default conditions) benefit from the same declaration file

Add `types` condition to the `.` exports entry in both `openapi-fetch`
and `openapi-typescript` packages so that modern TypeScript / tsgo
(Go-rewritten compiler) can resolve types deterministically from the
`dist/index.d.ts` files the packages already ship.

Without an explicit `types` condition, packages with `"type": "module"`
fall back to the legacy sibling-`.d.ts` resolver, which tsgo is
tightening against.

No behavioral change — pure manifest fix, two lines per package.
@mattconcord mattconcord requested a review from a team as a code owner May 18, 2026 15:56
@mattconcord mattconcord requested a review from gzm0 May 18, 2026 15:56
@netlify
Copy link
Copy Markdown

netlify Bot commented May 18, 2026

👷 Deploy request for openapi-ts pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit b132add

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 18, 2026

⚠️ No Changeset found

Latest commit: b132add

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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