Repository navigation
refactor(downgrader): drop the unreachable isRecord check on anyOf targets - #95
Conversation
…rgets `convertSchemaRef` only skipped adding a holder that isn't an object, which happens just for a kept `$ref` whose part before `/anyOf/` doesn't resolve. `anyOfTargets` is only queried with input schema objects, so adding the unresolved value is harmless, and branch coverage is back to 100%. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YNzPR6fb2NHVQPYKsD2eta
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.
Reviewed changes — the entire PR (1 file, 1 commit, +2/−5).
anyOfTargetswidened toSet<unknown>—packages/downgrader/src/v3.1-to-v3.0.ts:134.- Dropped the
isRecord(holder)guard inconvertSchemaRef—resolvePointer(...)is now added to the set unconditionally (packages/downgrader/src/v3.1-to-v3.0.ts:283).
I verified the safety argument independently. anyOfTargets is read only by anyOfTargets.has(input) in downgradeV30 (:801), where input is the schema half of a twoBranchAnyOfs tuple pushed in finishSchema (:671). finishSchema runs only from convertObject after the isRecord(value) early return (shared.ts:125), so input is always a non-null, non-array record. resolvePointer returns the raw input reference, so an object holder was already added under the old guard; adding undefined, null, or an array instead can never equal input, and isRecord is still used elsewhere in the file so the import stays live. Behavior is unchanged, and the local run confirms 258 downgrader tests pass with oxlint/oxfmt/tsc clean on the touched file.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Requested by dinwwwh · project thread
Problem
Since #92, branch coverage is 99.78%. In
convertSchemaRef(3.1 to 3.0),if (isRecord(holder))is only false for a kept$refwhose part before/anyOf/doesn't resolve, which no test hits.Fix
anyOfTargetsbecomes aSet<unknown>and the resolved value is added as is. The set is only queried with input schema objects indowngradeV30, so an unresolved value in it changes nothing. +2/−5.Checks
pnpm run checkpassesGenerated by Claude Code