• 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.

    Type Parameters

    • StateT

      The type of the state that was previously saved

    Returns StateT

    The previous saved state from the last invocation of the current thread

    const previousState = getPreviousState<{ counter: number }>();
    const newCount = (previousState?.counter ?? 0) + 1;