Skip to content

fix(types)!: remove the root entry to fix broken namespace types - #19

Merged
dinwwwh merged 1 commit into
mainfrom
claude/openapi-spec-namespace-exports-b5033a
Sep 26, 2026
Merged

dinwwwh merged 1 commit into
mainfrom
claude/openapi-spec-namespace-exports-b5033a

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Sep 26, 2026

Copy link
Copy Markdown
Member

The published @openapi-spec/types 0.1.0 has broken namespace types: OpenAPIV3_1.ContactObject, OpenAPIV3_1.TagObject, OpenAPIV3_2.SpecificationExtensions and 32 other names fail with TS2749, and just importing the package without skipLibCheck gives 35 errors inside dist. This PR removes the root entry that produced those namespaces. Versions are now imported only from their subpaths, which is a breaking change, so it should ship as 0.2.0.

Fixes

  • Every type works as a namespace member and as a direct import, with no errors in dist under skipLibCheck: false
  • Hovering a namespace member such as OpenAPIV3_1.InfoObject now shows its description, which 0.1.0 never did

Breaking change

import ... from '@openapi-spec/types' no longer resolves. Migration is one line per version, and code that uses the types stays the same:

import type * as OpenAPIV3_1 from '@openapi-spec/types/v3.1'

The published downgrader 0.1.0 depends on ^0.1.0, so it isn't affected. Its source here uses the new imports.

Why not a patch

Declaring the 35 re-exported types locally would also fix it without a breaking change. But those types would then lose their description on hover, and namespace access would still show no descriptions at all. Removing the root keeps the documentation, which is this package's main feature.

Testing

  • Lint, type-check, and all 350 tests pass
  • Packed both packages and compiled a separate project against them with skipLibCheck: false: all 141 exported types across 3.0–3.2 work as namespace members and as direct imports, the 35 reused types are identical to their originals, and the downgrader's published types work end to end
  • The same check against the current code reproduces the 35 dist errors

The declaration bundler turned the names v3.1 and v3.2 re-export into
values inside the root's OpenAPIV3_1 and OpenAPIV3_2 namespaces, so
types like OpenAPIV3_1.ContactObject failed with TS2749 and the
published dist had 35 errors without skipLibCheck. Only the root
entry creates those namespaces, so it is removed.

BREAKING CHANGE: `@openapi-spec/types` no longer has a root entry.
Import a version namespace from its subpath instead:
`import type * as OpenAPIV3_1 from '@openapi-spec/types/v3.1'`.
@codecov

codecov Bot commented Sep 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ No new issues found. Verified the fix end to end against a built dist with skipLibCheck: false, and confirmed all in-repo imports migrated.

Reviewed changes

  • Removed the package root entry — deleted packages/types/src/index.ts and the "." condition from exports/publishConfig.exports, so @openapi-spec/types no longer resolves at the root.
  • Migrated every in-repo consumer — packages/downgrader/src/*.ts, *.test.ts, and tests/*.test.ts now import per-version subpaths as namespaces (import type * as OpenAPIV3_1 from '@openapi-spec/types/v3.1').
  • Updated packages/types/README.md — usage snippet now shows the subpath namespace and direct-import forms.

I checked that unbuild infers entries from package.json exports, so removing "." and src/index.ts does not break prepack. I also built both packages, dropped the types dist into a scratch project using the published exports, and compiled a consumer with skipLibCheck: false: namespace members (OpenAPIV3_1.ContactObject, OpenAPIV3_2.SpecificationExtensions, OpenAPIV3_0.SchemaObject) and direct imports all resolve without errors. pnpm lint, pnpm type:check, and all 350 tests pass. No remaining root imports in tracked files.

ℹ️ The packed-dist type behavior has no automated guard

The bug this PR fixes only manifests in the built .d.mts (the published artifact), but CI never builds packages — it runs lint, type-check, and tests, and the build happens only at publish via prepack. The author's verification is therefore manual and not repeatable in CI, so a future change to the build entry inference or emitted declarations could reintroduce a namespace-types regression undetected. Not blocking for this PR; flagging it as the one gap the change leaves behind. If a guard is wanted later, a CI step that runs pnpm pack for packages/types and compiles a small fixture with skipLibCheck: false would cover it.

Pullfrog  | View workflow run | Using DeepSeek Flash (default — pick a model for stronger reviews) | 𝕏

@dinwwwh
dinwwwh merged commit 42cab5d into main Sep 26, 2026
7 checks passed
@dinwwwh
dinwwwh deleted the claude/openapi-spec-namespace-exports-b5033a branch September 27, 2026 13:04
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