A helper utility function for use with the functional API that returns the previous state from the checkpoint from the last invocation of the current thread.
This function allows workflows to access state that was saved in previous runs using entrypoint.final.
getPreviousState<StateT>(): StateTconst previousState = getPreviousState<{ counter: number }>();
const newCount = (previousState?.counter ?? 0) + 1;