TanStack / TanStack/form

Recursive Schema Causes Type Instantiation Is Excessively Deep or Infinite

Open
#1,830 1 comment 3 reactions 0 assignees View on GitHub

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

https://stackblitz.com/edit/sveltejs-kit-template-default-vqnfhqkw?file=src%2Froutes%2F%2Bpage.svelte

Steps to reproduce
  1. Clone the StackBlitz
  2. Run npm install
  3. 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
Image
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.