Improve TypeScript types of the assign method by adding type inference #7402
arnaugomez
started this conversation in
Ideas
Replies: 1 comment
-
I have created a TypeScript playground with the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Checked
Feature request
I would like to improve the type safety of the
assign
method of the Runnable class.The
assign
method returns aRunnable
with no types data:https://v03.api.js.langchain.com/classes/_langchain_core.runnables.Runnable.html#assign
Example:
However, with TypeScript's type inference mechanism, we can infer the types of the input and the output. My proposal is to improve the types to make this possible. The result would be:
Motivation
We can leverage TypeScript's type inference mechanism to improve the type safety of our application. This way, we can have autocompletion and type checking at every step of our chain.
Proposal (If applicable)
I have re-written the type declaration of the
assign
method so that it infers the return type.This is the code. Should I submit a PR with this change? I'm new to contributing to Langchain, so I don't know if I should wait for a maintainer to create an issue, before I create the PR.
Beta Was this translation helpful? Give feedback.
All reactions