openapi-typescript icon indicating copy to clipboard operation
openapi-typescript copied to clipboard

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

Open mattconcord opened this issue 6 months ago • 2 comments

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

mattconcord avatar May 18 '26 15:05 mattconcord

Deploy request for openapi-ts pending review.

Visit the deploys page to approve it

Name Link
Latest commit b132addf86d85c21a192de44fca746ed1cf41aae

netlify avatar May 18 '26 15:05 netlify

⚠️ No Changeset found

Latest commit: b132addf86d85c21a192de44fca746ed1cf41aae

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

changeset-bot[bot] avatar May 18 '26 15:05 changeset-bot[bot]