fix(types): define 3.1 LinkObject locally, add prepack hook, extend type tests - #9
Conversation
…ype tests - Define LinkObject in v3.1 against the 3.1 ServerObject instead of re-exporting the 3.0 type, per the module's own re-export rule. - Add a prepack build script so publishing always ships a fresh dist, matching the downgrader package. - Add @ts-expect-error tests for fields that belong to a later spec version (3.1-only fields in 3.0, 3.2-only fields in 3.1), header style restriction, and positive tests for referenced media types in 3.2 content maps.
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.
ℹ️ Two minor suggestions inline — otherwise this is mergeable as-is.
Reviewed changes — single commit 083815d across 5 files; I ran pnpm type:check, pnpm lint, and pnpm test (327 passing) and verified every version-boundary claim against the official OAS 3.0.4 / 3.1.2 / 3.2.0 spec text.
- 3.1
LinkObjectlocal definition —v3.1.tsstops re-exporting the 3.0LinkObjectand defines it locally against 3.1'sServerObject, fixing hover/docs pointing at the 3.0.4 type. Field set exactly matches the 3.1.2 spec; no gap. prepackbuild hook —packages/types/package.jsonswaps"build": "unbuild"for"prepack": "unbuild"so publishing always ships freshly builtdist.- 3.0 boundary tests — new
@ts-expect-errortests reject 3.1-only fields (info.summary,license.identifier,jsonSchemaDialect,components.pathItems,type: 'null',const) and non-simpleheader styles. - 3.1 boundary tests — 13 negative tests reject 3.2-only fields (response
summary,querystringlocation,cookiestyle,$self,components.mediaTypes, servername, tagparent,itemSchema,dataValue,defaultMapping, XMLnodeType, schemedeprecated, device-authorization flow). - 3.2 positive tests — Reference Objects accepted as content-map values in request body, response, and header.
Verification notes: because pnpm type:check (which covers *.test-d.ts via the root tsconfig) passes, every @ts-expect-error directive is "used" — i.e. it suppresses a real error — so the negative tests genuinely pin the version boundaries rather than passing vacuously. Every version-claim comment in the tests was independently confirmed against the official spec text (including the high-risk ones: Response summary is indeed 3.2-only, Server Object gains only name in 3.2, and Header style stays simple-only across all three versions); no over-strict types were found.
DeepSeek Flash (default — pick a model for stronger reviews) | 𝕏
The test claimed to cover both parent and kind but only exercised parent. TypeScript reports one excess property per object literal, so kind now lives in its own tag entry with its own @ts-expect-error.
There was a problem hiding this comment.
ℹ️ The incremental change cleanly closes the prior test-coverage gap; no new issues found.
Reviewed changes — single commit b47d4aa touching only packages/types/src/v3.1.test-d.ts; I re-ran pnpm type:check and lint to confirm the new directive is live.
- Tag
kindboundary now pinned — thenoTagHierarchytest negates the Tag Object's 3.2-onlykindfield (alongsideparent) with its own@ts-expect-error. Becausepnpm type:checkcovers*.test-d.tsand passes, the new directive genuinely suppresses an excess-property error rather than passing vacuously — confirmed againstTagObjectinv3.2.ts:1109vs the 3.1-re-exported 3.0 shape.
The one other thread from the prior review (the build → prepack script rename nit in package.json:67) was left unchanged by this commit and is the author's call — the PR remains mergeable as-is.
DeepSeek Flash (default — pick a model for stronger reviews) | 𝕏

Deep review of
@openapi-spec/types. Every interface's field list was cross-checked against the official OAS 3.0/3.1/3.2 JSON Schemas and matched; this PR fixes the two consistency and packaging gaps that turned up and adds the version-boundary type tests thattests/README.mdpreviously only described.Fixes
LinkObject. It referenced the 3.0ServerObjectwhile 3.1 redefines that type, so hover docs pointed at 3.0.4.LinkObjectis now defined inv3.1.tsagainst the 3.1ServerObject, in line with the module's re-export rule.dist: aprepackscript runsunbuild, matching@openapi-spec/downgrader.Testing
info.summary,license.identifier,jsonSchemaDialect,components.pathItems,type: "null",const), and Header Objects reject styles other thansimple.querystringlocation,cookiestyle,$self,components.mediaTypes, servername, tagparent/kind,itemSchema,dataValue,defaultMapping, XMLnodeType, security schemedeprecated, device authorization flow, responsesummary).pnpm type:check,pnpm lint,pnpm build, andpnpm test(327 tests) pass.Reviewer notes
200:against the template-literal index signature ofResponsesObject(string keys are checked). A stricter mapped-type version was tried and dropped; a[statusCode: number]index signature would close the gap at the cost of accepting numeric out-of-range codes.