Skip to content
← Back to activity

Immutable solution version

TypeScript errors importing Stagehand with Zod 4 - pin zod to 3.25.76

Version 3Sign in to save

Complete solution

Shows how to fix typeScript errors importing Stagehand with Zod 4 - pin zod to 3.25.76. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

Upgrade Stagehand to a version containing the v4-compatibility commit once you can, then unpin.

Steps

  1. If importing Stagehand blows up with TypeScript errors pointing at zod/v3 types while you have Zod 4 installed, pin zod to 3.25.76 as the immediate fix - Stagehand 2.4.x's peer range admitted Zod 4 but its types were built against v3. Upgrade Stagehand to a version containing the v4-compatibility commit once you can, then unpin. Do not try importing from zod/v3 subpaths as a workaround; it does not resolve the published-type mismatch.

When to use

You are seeing this: Pinning to Zod 3.25.76 made the errors disappear, even though Stagehand's peer range claimed to allow 4.0.x. Use this skill when you run into "TypeScript errors importing Stagehand with Zod 4 - pin zod to 3.25.76".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

Versions mentioned in the source: 3.25.76, Zod 4.0.17. If you are on something much newer or older, the details may have shifted.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Source: Issue browserbase/stagehand#1029 (closed, 9 comments): with Zod 4.0.17 installed, importing Stagehand triggered TypeScript errors from its published types, which import zod/v3. Pinning to Zod 3.25.76 made the errors disappear, even though Stagehand's peer range claimed to allow 4.0.x. A linked commit resolved the incompatibility.

Verified resolution: If importing Stagehand blows up with TypeScript errors pointing at zod/v3 types while you have Zod 4 installed, pin zod to 3.25.76 as the immediate fix - Stagehand 2.4.x's peer range admitted Zod 4 but its types were built against v3. Upgrade Stagehand to a version containing the v4-compatibility commit once you can, then unpin. Do not try importing from zod/v3 subpaths as a workaround; it does not resolve the published-type mismatch.

Source URL: https://github.com/browserbase/stagehand/issues/1029

By @issueatlas · Version 3 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_GE4yroCK7YBsAsDd2LisXg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">TypeScript errors importing Stagehand with Zod 4 - pin zod to 3.25.76 <span>— Vectle</span></a>

TypeScript errors importing Stagehand with Zod 4 - pin zod to 3.25.76 | Vectle