Skip to content

fix(react-form): declare @types/react as an optional peer dependency - #2474

Open
RaxRai wants to merge 1 commit into
TanStack:mainfrom
RaxRai:fix/react-types-optional-peer
Open

RaxRai wants to merge 1 commit into
TanStack:mainfrom
RaxRai:fix/react-types-optional-peer

Conversation

@RaxRai

@RaxRai RaxRai commented Nov 9, 2026 •

Copy link
Copy Markdown

Fixes #2472

🎯 Changes

The React packages ship type declarations that import from react, but they don't declare @types/react. With install layouts where @types/react can't be resolved from the package's real path (for example pnpm's global virtual store, virtualStoreType: global), TypeScript resolves the untyped react/index.js. Every React type in these declarations then silently becomes any, and consumers get errors like TS7006 in their own code.

This adds @types/react as an optional peer dependency, using the same range as the existing react peer (^17.0.0 || ^18.0.0 || ^19.0.0), to:

  • @tanstack/react-form
  • @tanstack/react-form-devtools
  • @tanstack/react-form-nextjs
  • @tanstack/react-form-remix
  • @tanstack/react-form-start

Because the peer is optional, JavaScript consumers are unaffected. @tanstack/react-query does the same thing in packages/react-query/package.json.

pnpm-lock.yaml does not change.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm test:pr, or these tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Compatibility
    • React Form packages now support React type definitions for versions 17, 18, and 19 when they’re present, without requiring them to be installed.

The React packages ship type declarations that import from `react`
but did not declare `@types/react`. With install layouts where it is
not resolvable from the package's real path (e.g. pnpm's global
virtual store), React types silently became `any`.

Fixes TanStack#2472

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Nov 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 08903d9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
@tanstack/react-form Patch
@tanstack/react-form-devtools Patch
@tanstack/react-form-nextjs Patch
@tanstack/react-form-remix Patch
@tanstack/react-form-start Patch
@tanstack/angular-form Patch
@tanstack/form-core Patch
@tanstack/solid-form Patch
@tanstack/svelte-form Patch
@tanstack/vue-form Patch
@tanstack/form-devtools Patch
@tanstack/solid-form-devtools Patch
@tanstack/lit-form Patch
@tanstack/preact-form Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Five React Form packages now declare @types/react versions 17–19 as an optional peer dependency. A changeset declares patch releases for those packages.

Changes: React type peer declarations

Layer / File(s) Summary
Optional React type peer declarations
packages/react-form/package.json, packages/react-form-devtools/package.json, packages/react-form-nextjs/package.json, packages/react-form-remix/package.json, packages/react-form-start/package.json, .changeset/react-types-optional-peer.md
The five package manifests add optional @types/react peer dependencies for versions 17–19. The changeset declares patch releases for these packages.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: crutchcorn, harry-whorlow

Merge Risk: Minimal · up to 08903

The optional peers are intended to improve React type resolution without requiring types for JavaScript consumers. No concrete merge-blocking issue was identified.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title names the main change: adding @types/react as an optional peer dependency to the react-form package. It is specific and matches the changeset. It uses the conventional fix(scope) prefix. It …
Description check Passed The description follows the template. It has the Changes section, which explains the problem (type declarations import from react without declaring @types/react, so types can become any under layouts …
Linked Issues check Passed Issue #2472 requires @tanstack/react-form to declare @types/react as an optional peer dependency, with a range that may mirror the existing react peer range. At head, `packages/react-form/packag…
Out of Scope Changes check Passed The PR changes are the @types/react optional peer declaration in five React package manifests, plus .changeset/react-types-optional-peer.md. The changeset names the same five packages as patch rel…
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Title check

Explanation

The title names the main change: adding @types/react as an optional peer dependency to the react-form package. It is specific and matches the changeset. It uses the conventional fix(scope) prefix. It does not cover the other four React packages, but that detail is expected and the title is still related to the main change.

Full details: Description check

Explanation

The description follows the template. It has the Changes section, which explains the problem (type declarations import from react without declaring @types/react, so types can become any under layouts such as pnpm's global virtual store) and the fix (an optional @types/react peer with the same range as react). It links the issue (#2472), lists all five affected packages, and states that the lockfile does not change. The Checklist and Release Impact sections are filled in. The first checklist item is checked, and the changeset item is checked. The unchecked testing item says pnpm test:pr was not run. The author leaves this unchecked, which is allowed when tests do not apply, but the PR does not explain why it was not run. The description is mostly complete.

Full details: Linked Issues check

Explanation

Issue #2472 requires @tanstack/react-form to declare @types/react as an optional peer dependency, with a range that may mirror the existing react peer range. At head, packages/react-form/package.json lists "@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0" under peerDependencies and "@types/react": { "optional": true } under peerDependenciesMeta. The range matches the react peer range. This meets the issue's suggested fix. The issue requests no automated test and no non-coding work. The PR checklist states that pnpm test:pr was not run. That is a verification step, not a linked-issue coding requirement. Verified directly: packages/react-form/package.json and packages/react-form-start/package.json at head. The same change in react-form-devtools, react-form-nextjs, and react-form-remix is taken from the PR summary and was not read directly. Those packages are not named in issue #2472, so their status does not affect this result.

Full details: Out of Scope Changes check

Explanation

The PR changes are the @types/react optional peer declaration in five React package manifests, plus .changeset/react-types-optional-peer.md. The changeset names the same five packages as patch releases and describes the same change. The changeset is a release artifact for a published change, so it is in scope. Verified directly: the react-form and react-form-start manifests and the changeset. The react-form-devtools, react-form-nextjs, and react-form-remix manifest changes are taken from the PR summary and were not read directly. Those three packages ship type declarations that import from react, the same root cause as issue #2472. Adding the same optional peer to them is a related change, not an unrelated one. The PR summary reports that pnpm-lock.yaml is unchanged. No unrelated change was found in the evidence.

Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 0 files. (6 skipped: 6 unsupported.)

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: TanStack/form
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: eba4084
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 58a22b5d-9916-436b-ac67-d1b2710daa68
Commits

Reviewing files that changed from the base of the PR and between eba4084 and 08903d9.

Files selected for processing: 6

  • .changeset/react-types-optional-peer.md
  • packages/react-form-devtools/package.json
  • packages/react-form-nextjs/package.json
  • packages/react-form-remix/package.json
  • packages/react-form-start/package.json
  • packages/react-form/package.json

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@tanstack/react-form: declare @types/react as an optional peer dependency

1 participant