fix(types)!: remove the root entry to fix broken namespace types - #19
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
✅ No new issues found. Verified the fix end to end against a built
distwithskipLibCheck: false, and confirmed all in-repo imports migrated.
Reviewed changes
- Removed the package root entry — deleted
packages/types/src/index.tsand the"."condition fromexports/publishConfig.exports, so@openapi-spec/typesno longer resolves at the root. - Migrated every in-repo consumer —
packages/downgrader/src/*.ts,*.test.ts, andtests/*.test.tsnow 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.
DeepSeek Flash (default — pick a model for stronger reviews) | 𝕏

The published
@openapi-spec/types0.1.0 has broken namespace types:OpenAPIV3_1.ContactObject,OpenAPIV3_1.TagObject,OpenAPIV3_2.SpecificationExtensionsand 32 other names fail with TS2749, and just importing the package withoutskipLibCheckgives 35 errors insidedist. 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
distunderskipLibCheck: falseOpenAPIV3_1.InfoObjectnow shows its description, which 0.1.0 never didBreaking change
import ... from '@openapi-spec/types'no longer resolves. Migration is one line per version, and code that uses the types stays the same: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
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 enddisterrors