Partial fix: strip required from anyOf/oneOf schema items to reduce TS2615 circular reference errors#3694
Draft
Partial fix: strip required from anyOf/oneOf schema items to reduce TS2615 circular reference errors#3694
required from anyOf/oneOf schema items to reduce TS2615 circular reference errors#3694Conversation
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 |
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.
Schemas with circular
anyOf/oneOfreferences (e.g. aFilterGroupthat containsanyOf: [FilterGroup, SoloFilter]) cause TypeScript error TS2615 ("Type of property X circularly references itself in mapped type") whenjson-schema-to-ts'sParseObjectSchemamaps over required fields whose types involve the circular schema.Changes
packages/fets/src/client/types.ts: AddedFixAnyOfOneOfRequiredFieldstransformation toFixJSONSchemapipeline. Uses the same HotScriptCall<Tuples.Map<Objects.Omit<'required'>>, T['anyOf']>pattern as the existingFixAdditionalPropertiesForAllOfto striprequiredfrom items insideanyOf/oneOfarrays. This prevents the circular required-fields mapped type check ints-algebra's_$Objectfrom triggering TS2615 for inner schemas.packages/fets/tests/client/fixtures/example-anyof-circular-ref-oas.ts: Test fixture reproducing the reported OAS spec with a self-referencingFilterGroupschema.packages/fets/tests/client/anyof-circular-ref-test.ts: Test file documenting the issue.Known limitation
This is a partial fix. Stripping
requiredfromanyOf/oneOfitems prevents TS2615 in inner schemas, but TS2615 still occurs when the outer component schema (e.g.FilterGroupincomponents/schemas) has required fields that include the circular property. The cycle injson-schema-to-ts'sParseAnyOfSchema→MergeSubSchemapath creates intermediate types that TypeScript cannot recognize as safe deferred recursion, even withrequiredstripped.The complete fix requires keeping
$refstubs (unexpanded) foranyOf/oneOfitems inResolveRefsInObjand passing the full normalized OAS asrootSchematoFromSchemacalls, so thatParseReferenceSchemahandles the cycle lazily instead ofParseAnyOfSchema.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:
api.clickhouse.cloud/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/feTS/feTS/node_modules/.bin/ts-node scripts/download-oas.ts(dns block)api.navitia.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/feTS/feTS/node_modules/.bin/ts-node scripts/download-oas.ts(dns block)api.pulumi.com/usr/local/bin/pulumi pulumi plugin install resource aws v5.43.0(dns block)/usr/local/bin/pulumi pulumi plugin install resource docker v3.6.1(dns block)/usr/local/bin/pulumi pulumi plugin install resource cloudflare v4.16.0(dns block)developer.spotify.com/home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/feTS/feTS/node_modules/.bin/ts-node scripts/download-oas.ts(dns block)scarf.sh/home/REDACTED/work/_temp/ghcca-node/node/bin/node node ./report.js(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 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.