import { Annotation } from "@langchain/langgraph"
const PlanExecuteState = Annotation.Root({
input: Annotation({
reducer: (x, y) => y ?? x ?? "",
}),
plan: Annotation({
reducer: (x, y) => y ?? x ?? [],
}),
pastSteps: Annotation({
reducer: (x, y) => x.concat(y),
}),
response: Annotation({
reducer: (x, y) => y ?? x,
}),
})
With a JavaScript kernel, on a new notebook, fails with this error:
11:24 - Property 'concat' does not exist on type 'unknown'.
It appears Type Checking is somehow still active even with the JavaScript kernel selected. Changing the code like this and choosing the TypeScript kernel, works:
import { Annotation } from "@langchain/langgraph"
const PlanExecuteState = Annotation.Root({
input: Annotation({
reducer: (x, y) => y ?? x ?? "",
}),
plan: Annotation({
reducer: (x, y) => y ?? x ?? [],
}),
pastSteps: Annotation({
reducer: (x: any, y) => x.concat(y),
}),
response: Annotation({
reducer: (x, y) => y ?? x,
}),
})
Furthermore, running the first (un-typed) code snippet in a regular node ".js" file runs fine with no runtime errors.
Lastly, this happens only when importing the Annotation class, for example, this code works perfectly fine in a notebook with JavaScript kernel:
Running the following code (taken from the notebooks provided in the tutorials for LangGraphJS):
With a JavaScript kernel, on a new notebook, fails with this error:
It appears Type Checking is somehow still active even with the JavaScript kernel selected. Changing the code like this and choosing the TypeScript kernel, works:
Furthermore, running the first (un-typed) code snippet in a regular node ".js" file runs fine with no runtime errors.
Lastly, this happens only when importing the Annotation class, for example, this code works perfectly fine in a notebook with JavaScript kernel:
What am I missing?