Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

debugging.md

63 lines2.0 KB

1---
2id: debugging
3title: Debugging Solid Usage
4---
5​
6This page covers common Solid and TypeScript problems when using TanStack Form.
7​
8## An input does not start with the expected value
9​
10Every value rendered by an input should exist in form-level `defaultValues`
11when the form is created.
12​
13```tsx
14import { createForm } from '@tanstack/solid-form'
15​
16const form = createForm(() => ({
17 defaultValues: {
18 firstName: '',
19 subscribed: false,
20 },
21}))
22```
23​
24Do not omit `defaultValues` or rely on a field-level default. When values come
25from an API, render a loading state before mounting the editable form or supply
26a complete fallback shape.
27​
28## A field value is `unknown`
29​
30Field names and values are inferred from `defaultValues`. Check that you have
31not widened the initial object to `Record<string, unknown>`, `any`, or an
32unrelated union. Prefer a concrete value type:
33​
34```tsx
35import { createForm } from '@tanstack/solid-form'
36​
37type Profile = { firstName: string; age: number }
38​
39const defaults: Profile = { firstName: '', age: 0 }
40const form = createForm(() => ({ defaultValues: defaults }))
41```
42​
43For extremely large forms, split UI into typed components or scoped form and
44field groups instead of casting each field value.
45​
46## Type instantiation is excessively deep
47​
48This TypeScript error usually involves a very large recursive value shape, a
49widely inferred union, or an unsupported composition. Reduce it to the smallest
50form that reproduces the problem, keep `defaultValues` concrete, and avoid
51unnecessary generic wrappers.
52​
53If the minimal reproduction still fails, report it in the
54[TanStack Form issue tracker](https://github.com/TanStack/form/issues). Include
55the TypeScript and Solid versions, the form value type, and the smallest failing
56field.
57​
58## Errors exist but are not displayed
59​
60`field().errors` respects the form's `errorVisibility` policy. Inspect
61`field().meta.original.errors` when debugging whether validation ran but the
62issues are intentionally hidden. Also confirm that the input calls
63`field().handleBlur` if the policy depends on `isBlurred`.