Packages

xstate

5.33.4 · 7 Nov 2026MIT9M / weekRepositoryHomepagenpmAtom feed

Your version

4.20.1

25 Jun 2021Where it was published

4.38.3 is the newest release of 4.x.

In short

1 deprecated3 fixed

  • Deprecated

    The SpawnedActorRef TypeScript interface has been deprecated in favor of a unified ActorRef interface, which contains the following:

Release note

Patch Changes

  • Deprecated

    The SpawnedActorRef TypeScript interface has been deprecated in favor of a unified ActorRef interface, which contains the following:

    interface ActorRef<TEvent extends EventObject, TEmitted = any>
      extends Subscribable<TEmitted> {
      send: (event: TEvent) => void;
      id: string;
      subscribe(observer: Observer<T>): Subscription;
      subscribe(
        next: (value: T) => void,
        error?: (error: any) => void,
        complete?: () => void
      ): Subscription;
      getSnapshot: () => TEmitted | undefined;
    }

    For simpler actor-ref-like objects, the BaseActorRef<TEvent> interface has been introduced.

    interface BaseActorRef<TEvent extends EventObject> {
      send: (event: TEvent) => void;
    }
  • When using a model type in createMachine<typeof someModel>(...), TypeScript will no longer compile machines that are missing the context property in the machine configuration:

    const machine = createMachine<typeof someModel>({
      // missing context - will give a TS error!
      // context: someModel.initialContext,
      initial: 'somewhere',
      states: {
        somewhere: {}
      }
    });
  • The typing for InvokeCallback have been improved for better event constraints when using the sendBack parameter of invoked callbacks:

    invoke: () => (sendBack, receive) => {
      // Will now be constrained to events that the parent machine can receive
      sendBack({ type: 'SOME_EVENT' });
    };
  • The state.meta value is now calculated directly from state.configuration. This is most useful when starting a service from a persisted state:

      const machine = createMachine({
        id: 'test',
        initial: 'first',
        states: {
          first: {
            meta: {
              name: 'first state'
            }
          },
          second: {
            meta: {
              name: 'second state'
            }
          }
        }
      });
    
      const service = interpret(machine);
    
      service.start('second'); // `meta` will be computed
    
      // the state will have
      // meta: {
      //   'test.second': {
      //     name: 'second state'
      //   }
      // }
    });

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.