TanStackT
TanStack12mo ago
6 replies
popular-magenta

Type instantiation is excessively deep and possibly infinite

Hey there! I was testing https://conform.guide with the start-counter example and encountered this weird type error. Everything works perfectly at runtime. The repro is quite simple, just install conform:
npm i @conform-to/react @conform-to/zod zod

and then in any page:
import { createFileRoute } from "@tanstack/react-router"
import { createServerFn } from "@tanstack/start"
import { parseWithZod } from "@conform-to/zod"
import { z } from "zod"

const schema = z.object({
  username: z.string(),
})

const serverFn = createServerFn({ method: "POST" })
  .validator((data: FormData) => data)
  .handler(async (options) => {
    const submission = parseWithZod(options.data, { schema })
    return submission.reply() // Throws the type error
  })

export const Route = createFileRoute("/")({
  component: Home,
})

function Home() {
  return (
    <form
      action={serverFn.url}
      method="post"
      encType="multipart/form-data"
    >
      <input type="text" name="username" />
      <button>Submit</button>
    </form>
  )
}
image.png
Was this page helpful?