Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does tslab enforce type checking even when using the JavaScript kernel? #103

Open
indicava opened this issue Oct 6, 2024 · 0 comments
Open

Comments

@indicava
Copy link

indicava commented Oct 6, 2024

Running the following code (taken from the notebooks provided in the tutorials for LangGraphJS):

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:

const y = {
    a: "test",
    b: (x, y) => x.concat(y),
}

y.b(y.a, y.a)

What am I missing?

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

No branches or pull requests

1 participant