Partial fix: strip required from anyOf/oneOf schema items to reduce TS2615 circular reference errors#3694
Draft
Copilot wants to merge 7 commits into
Draft
Partial fix: strip required from anyOf/oneOf schema items to reduce TS2615 circular reference errors#3694Copilot wants to merge 7 commits into
required from anyOf/oneOf schema items to reduce TS2615 circular reference errors#3694Copilot wants to merge 7 commits into
Conversation
Agent-Logs-Url: https://github.com/ardatan/feTS/sessions/c2d8eec9-96bd-4af6-a1c7-65ddf2986403 Co-authored-by: ardatan <20847995+ardatan@users.noreply.github.com>
…duce TS2615 circular reference errors Agent-Logs-Url: https://github.com/ardatan/feTS/sessions/c2d8eec9-96bd-4af6-a1c7-65ddf2986403 Co-authored-by: ardatan <20847995+ardatan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix circular reference error in OpenAPI spec
Partial fix: strip Mar 30, 2026
required from anyOf/oneOf schema items to reduce TS2615 circular reference errors
Contributor
💻 Website PreviewThe latest changes are available as preview in: https://3e60071d.fets.pages.dev |
Contributor
✅ Benchmark Results |
Owner
Agent-Logs-Url: https://github.com/ardatan/feTS/sessions/37428b70-e9d5-4898-b09f-0bdcd89cf1c7 Co-authored-by: ardatan <20847995+ardatan@users.noreply.github.com>
…5-4898-b09f-0bdcd89cf1c7 Co-authored-by: ardatan <20847995+ardatan@users.noreply.github.com>
Contributor
Author
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Agent-Logs-Url: https://github.com/ardatan/feTS/sessions/2b95da3e-6eba-4d79-9e20-a3b303b0f41a Co-authored-by: ardatan <20847995+ardatan@users.noreply.github.com>
…DirectType
Add HasCircularAnyOfRef<T> detection and DirectType<T> recursive type alias
so that FromSchema<T> uses a cycle-safe computation path for schemas containing
circular anyOf/oneOf $ref items, avoiding TS2615 entirely.
- HasCircularAnyOfRef<T> detects whether any property's anyOf/oneOf items
carry the $id marker added by ResolveRef (i.e. they are $ref-expanded).
- DirectType<T> is a named recursive generic type alias that TypeScript
evaluates lazily (same as `type Tree<T> = { value: T; children: Tree<T>[] }`),
so when the recursion leads back to DirectType<MutableResolvedFG> the
compiler defers instead of triggering TS2615.
- FromSchema<T> now checks HasCircularAnyOfRef<T> first and uses DirectType
for circular anyOf schemas, falling back to FromSchemaOriginal for all others.
Agent-Logs-Url: https://github.com/ardatan/feTS/sessions/2b95da3e-6eba-4d79-9e20-a3b303b0f41a
Co-authored-by: ardatan <20847995+ardatan@users.noreply.github.com>
|
@ardatan any luck? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
OpenAPI schemas that use
anyOf/oneOfto model circular (self-referential) types caused TypeScript error TS2615 when usingOASModel,OASOutput, or the feTS client. The root cause:json-schema-to-ts'sMergeSubSchema<{}, T>produces an anonymousOmit<>intersection type, breaking TypeScript's cycle-detection and causing TS2615.Solution
Added to
packages/fets/src/types.ts:HasCircularAnyOfRef<T>– detects schemas withanyOf/oneOfitems carrying the$idmarker (added byResolveReffor$ref-expanded schemas)DirectType<T>(exported) – a named recursive generic type alias that TypeScript evaluates lazily, the same waytype Tree<T> = { value: T; children: Tree<T>[] }works; prevents TS2615 by keeping recursive calls as the same named type alias instantiation instead of an anonymous mapped typeFromSchema<T>updated – routes schemas whereHasCircularAnyOfRef<T>istruethroughDirectType<T>; falls back toFromSchemaOriginalfor all other schemasProgress
FixSchemaWithIdalone didn't fix TS2615 — 3 errors remain inanyof-circular-ref-test.tsHasCircularAnyOfRef<T>,ContainsAnyOfWithId<T>,AnyHasId<Items>helper typesDirectType<T>,DirectUnionType<Items>,DirectIntersectionType<Items>typesFromSchema<T>to useDirectType<T>whenHasCircularAnyOfRef<T>is trueanyof-circular-ref-test.tsresolvedcircular-ref-test.ts,circular-ref-array-test.ts,mutual-circular-ref-test.ts,oas-test.tsstill pass💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.