Capítulo 5 de 29

Chapter 5: TypeScript

Core Idea

TanStack Form requires strict: true and TypeScript 5.4+, and treats its own type layer as exempt from semver — meaning type behavior can change on a patch release, so pinning an exact version matters more than usual.

Key Concepts

  • "strict": true is required in tsconfig.json for the inference guarantees (ch003, ch028's DeepKeys) to hold.
  • Minimum TypeScript 5.4.
  • Types are versioned outside semver: "changes to types in this repository are considered non-breaking" — a patch bump can tighten or change inferred types even though the runtime API didn't change.
  • Practical mitigation: pin an exact version ("@tanstack/react-form": "1.0.5", no ^/~) instead of a range, so a CI machine and a teammate's machine can't silently diverge on inferred types.

Reference Tables

RequirementValue
tsconfig.json"strict": true
Minimum TypeScript5.4
Recommended version pinexact (no ^/~) on the framework package

Key Takeaways

  1. If deep field types stop resolving correctly after an upgrade, check whether strict got disabled somewhere (a shared base tsconfig is a common culprit) before filing a bug.
  2. Don't use ^/~ ranges on the TanStack Form package in a team repo — an unpinned patch bump can change inferred types under someone's feet.
  3. "Excessively deep type instantiation" TypeScript errors (ch023 Debugging) are a known class of issue tied to this same inference machinery, not necessarily your form's fault.

Connects To

  • Ch028 Utility & State Types: DeepKeys/DeepValue, the inference primitives this depends on.
  • Ch023 Debugging: the "unknown field value" and "deep type instantiation" failure modes this chapter's constraints help avoid.