StateTypeCheck
Unpublished development API. This package is under development and is not available as a published release.
Resolves to unknown for a state type a session can hold, and to a sentence
naming the problem for one it cannot. Used as a constraint so the sentence is
what the compiler reports. any satisfies every constraint, so it is the one
unusable type this cannot reject.
import type { StateTypeCheck } from '@threadplane/core';Declaration
export type StateTypeCheck<TState> = unknown extends TState ? 'State needs a declared shape. Leave the state type out to keep it untyped.' : [TState] extends [object] ? [TState] extends [readonly unknown[]] ? 'State must be an object, not an array.' : [TState] extends [Portable<TState>] ? unknown : 'State must be plain data. Functions and class instances such as Date cannot be held in a snapshot.' : 'State must be an object.';Type parameters
TState