LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
React SDK
Vue SDK
Svelte SDK
Angular SDK
LangGraph SDK
  • Ui
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Utils
  • Server
  • Stream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
  • Store
LangGraph Checkpoint Redis
  • Shallow
  • Store
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
  • Cli
LangGraph API
LangGraph CLI
LangGraph CUA
  • Utils
LangGraph Supervisor
LangGraph Swarm
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangGraph
WebChannelsPregelPrebuiltRemote
React SDK
Vue SDK
Svelte SDK
Angular SDK
LangGraph SDK
UiClientAuthReactLoggingReact UiUtilsServerStream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
Store
LangGraph Checkpoint Redis
ShallowStore
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
Cli
LangGraph API
LangGraph CLI
LangGraph CUA
Utils
LangGraph Supervisor
LangGraph Swarm
Language
Theme
JavaScript@langchain/langgraphwebStateSchemaFieldToChannel
Type●Since v0.3

StateSchemaFieldToChannel

Maps a single StateSchema field definition to its corresponding Channel type.

This utility type inspects the type of the field and returns an appropriate BaseChannel type, parameterized with the state "value" and "input" types according to the field's shape.

Rules:

  • If the field (F) is a ReducedValue<V, I>, the channel will store values of type V and accept input of type I.
  • If the field is a UntrackedValue<V>, the channel will store and accept values of type V.
  • If the field is a SerializableSchema<I, O>, the channel will store values of type O (the schema's output/validated value) and accept input of type I.
  • For all other types, a generic BaseChannel<unknown, unknown> is used as fallback.
Copy
StateSchemaFieldToChannel: F extends ReducedValue<
  V,
  I
>  BaseChannel<V, OverwriteValue<V> | I> : F extends UntrackedValue<V>  BaseChannel<V, V> : F extends SerializableSchema<I, O>  BaseChannel<O, I> : BaseChannel<unknown, unknown>

Example

Copy
type MyField = ReducedValue<number, string>;
type ChannelType = StateSchemaFieldToChannel<MyField>;
// ChannelType is BaseChannel<number, string>
View source on GitHub