Skip to content

Using zod 4.0 results in TypeScript error not assignable to parameter of type 'never' #1472

@froitag

Description

@froitag

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangGraph.js documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangGraph.js rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangGraph (or the specific integration package).

Example Code

import "@langchain/langgraph/zod";
import { StateGraph } from "@langchain/langgraph";
import { z } from "zod";

const AgentState = z.object({
	question: z.string(),
	answer: z.string().min(1),
});

const graph = new StateGraph(AgentState);

Error Message and Stack Trace (if applicable)

No overload matches this call.
  The last overload gave the following error.
    Argument of type 'ZodObject<{ question: ZodString; answer: ZodString; }, $strip>' is not assignable to parameter of type 'never'.ts(2769)
state.d.ts(142, 5): The last overload is declared here.

Description

Trying to use the latest zod release (4.0) in a StateGraph results in the famous not assignable to parameter of type 'never' typescript error.

It seems that running the code doesn't produce a runtime error. But validation (via import "@langchain/langgraph/zod") doesn't seem to happen either.

System Info

  • @langchain/langgraph: 0.4.0
  • zod: 4.0.11
  • Package manager: bun

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions