Recursive Schema Causes Type Instantiation Is Excessively Deep or Infinite
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.7k
- Forks
- 682
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 7
Description
Describe the bug
I am using a necessarily recursive schema for a feature to store logic as JSON. We're unable to actually have type validation due to the Type instantiation is excessively deep and possibly infinite error that shows up. I used the most recent zod syntax for the recursive schema as well.
Your minimal, reproducible example
Steps to reproduce
- Clone the StackBlitz
- Run
npm install - Open the +page.svelte file in your editor
Expected behavior
In my editor, I would like to still see type hints without type errors. I understand that type depth might be limited, but since I am using recursive components I am not actually managing this entirely in the UI.
How often does this bug happen?
Every time
Screenshots or Videos
Platform
- OS: MacOS
- Browser: Chrome
TanStack Form adapter
None
TanStack Form version
v1.23.8
TypeScript version
v5.9.2
Additional context
I am using svelte-form, but that's not an option, you should add it to the TanStack Form adapter options for the GH issue form.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by opening the linked StackBlitz, running npm install, and inspecting src/routes/+page.svelte with TypeScript 5.9.2. Reproduce the recursive-schema type error in the editor and determine whether it originates in the form usage or its type definitions; done means the example retains type hints without the excessive-depth error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100