Skip to content

Conversation

kolvian
Copy link
Contributor

@kolvian kolvian commented Oct 3, 2025

Update Zod function schemas to use v4 API syntax:

  • Replace z.function().args(z.string()) with z.function(z.tuple([z.string()]), z.any())
  • Update moduleTypeProvider and flowTypeProvider in Environment.ts
  • Allow both Zod v3 and v4 in package dependencies (^3.22.4 || ^4.0.0)

This fixes the crash when users have Zod v4 installed, where the .args() method no longer exists. The new API is compatible with both Zod v3.23+ and v4.x.

How did you test this change?

  • Built both babel-plugin-react-compiler and eslint-plugin-react-hooks successfully with the updated Zod v4 API syntax
  • Verified the plugin loads correctly and exposes all 29 ESLint rules without the TypeError: zod.z.function(...).args is not a function crash

Update Zod function schemas to use v4 API syntax:
- Replace z.function().args(z.string()) with z.function(z.tuple([z.string()]), z.any())
- Update moduleTypeProvider and flowTypeProvider in Environment.ts
- Allow both Zod v3 and v4 in package dependencies (^3.22.4 || ^4.0.0)

This fixes the crash when users have Zod v4 installed, where the
.args() method no longer exists. The new API is compatible with
both Zod v3.23+ and v4.x.

Fixes TypeError: zod.z.function(...).args is not a function
Copy link

meta-cla bot commented Oct 3, 2025

Hi @kolvian!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla bot added the CLA Signed label Oct 3, 2025
Copy link

meta-cla bot commented Oct 3, 2025

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

Copy link
Member

@josephsavona josephsavona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome thank you!

@react-sizebot
Copy link

Comparing: 19f65ff...573484a

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB +0.11% 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 536.14 kB 536.14 kB = 94.81 kB 94.81 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB +0.05% 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 663.96 kB 663.96 kB = 117.04 kB 117.04 kB
facebook-www/ReactDOM-prod.classic.js = 687.83 kB 687.83 kB = 121.08 kB 121.08 kB
facebook-www/ReactDOM-prod.modern.js = 678.26 kB 678.26 kB = 119.44 kB 119.44 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against 573484a

Copy link
Member

@josephsavona josephsavona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this breaks a bunch of things, i'll try to fix it up locally

@josephsavona
Copy link
Member

Moving to #34717 to fix up the issues. Thanks for the PR!

josephsavona pushed a commit that referenced this pull request Oct 3, 2025
…gs, return)` to be compatible across Zod v3 and v4, but Zod 4's function API has completely changed. Instead, I've updated to just use `z.any()` where we expect a function, and manually validate that it's a function before we call the value. We already have validation of the return type (also using Zod).
josephsavona pushed a commit that referenced this pull request Oct 3, 2025
Partial redo of #34710. The changes there tried to use `z.function(args, return)` to be compatible across Zod v3 and v4, but Zod 4's function API has completely changed. Instead, I've updated to just use `z.any()` where we expect a function, and manually validate that it's a function before we call the value. We already have validation of the return type (also using Zod).
josephsavona pushed a commit that referenced this pull request Oct 3, 2025
Partial redo of #34710. The changes there tried to use `z.function(args, return)` to be compatible across Zod v3 and v4, but Zod 4's function API has completely changed. Instead, I've updated to just use `z.any()` where we expect a function, and manually validate that it's a function before we call the value. We already have validation of the return type (also using Zod).
josephsavona pushed a commit that referenced this pull request Oct 3, 2025
Partial redo of #34710. The changes there tried to use `z.function(args, return)` to be compatible across Zod v3 and v4, but Zod 4's function API has completely changed. Instead, I've updated to just use `z.any()` where we expect a function, and manually validate that it's a function before we call the value. We already have validation of the return type (also using Zod).
josephsavona added a commit that referenced this pull request Oct 3, 2025
Partial redo of #34710. The changes there tried to use `z.function(args,
return)` to be compatible across Zod v3 and v4, but Zod 4's function API
has completely changed. Instead, I've updated to just use `z.any()`
where we expect a function, and manually validate that it's a function
before we call the value. We already have validation of the return type
(also using Zod).

Co-authored-by: kolvian <eliot@pontarelli.com>
github-actions bot pushed a commit that referenced this pull request Oct 3, 2025
Partial redo of #34710. The changes there tried to use `z.function(args,
return)` to be compatible across Zod v3 and v4, but Zod 4's function API
has completely changed. Instead, I've updated to just use `z.any()`
where we expect a function, and manually validate that it's a function
before we call the value. We already have validation of the return type
(also using Zod).

Co-authored-by: kolvian <eliot@pontarelli.com>

DiffTrain build for [d6eb735](d6eb735)
github-actions bot pushed a commit that referenced this pull request Oct 3, 2025
Partial redo of #34710. The changes there tried to use `z.function(args,
return)` to be compatible across Zod v3 and v4, but Zod 4's function API
has completely changed. Instead, I've updated to just use `z.any()`
where we expect a function, and manually validate that it's a function
before we call the value. We already have validation of the return type
(also using Zod).

Co-authored-by: kolvian <eliot@pontarelli.com>

DiffTrain build for [d6eb735](d6eb735)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants