type
Unpublished development API. This package is under development and is not available as a published release.
Declares a session's state type without a schema.
import { type } from '@threadplane/core';Declaration · overload 1
export declare function type<TState extends TCheck, TCheck = StateTypeCheck<TState>>(): StateWitness<TState>;Type parameters
TStateTCheckTCheckDefault:StateTypeCheck<TState>
Returns
StateWitness<TState>Examples
const session = createSession({
...options,
stateType: type<{ todos: Todo[]; draft?: string }>(),
});
session.getSnapshot().state?.todos; // readonly Todo[]The session does not check what the backend sends. Pass a Standard Schema,
such as a Zod object, in place of type() to have each state checked as it
arrives.