Improve TypeScript types of the pick method by adding type inference #7394
arnaugomez
started this conversation in
Ideas
Replies: 1 comment
-
I created this TypeScript playground where you can try it out and see the type inference in action. |
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
pick
method of theRunnable
class.The
pick
method returns a Runnable with no types data:https://v03.api.js.langchain.com/classes/_langchain_core.runnables.Runnable.html#pick
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 and avoid having to declare the types of our Runnables explicitly at every step of the chain.
Proposal (If applicable)
I have re-written the type declaration of the
pick
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