github statelyai/xstate xstate@4.25.0

latest releases: @xstate/vue@4.0.0, @xstate/store@2.6.1, @xstate/svelte@4.0.0...
3 years ago

Minor Changes

  • #2657 72155c1b7 Thanks @mattpocock! - Removed the ability to pass a model as a generic to createMachine, in favour of model.createMachine. This lets us cut an overload from the definition of createMachine, meaning errors become more targeted and less cryptic.

    This means that this approach is no longer supported:

    const model = createModel({});
    
    const machine = createMachine<typeof model>();

    If you're using this approach, you should use model.createMachine instead:

    const model = createModel({});
    
    const machine = model.createMachine();

Patch Changes

  • #2659 7bfeb930d Thanks @Andarist! - Fixed a regression in the inline actions type inference in models without explicit action creators.

    const model = createModel(
      { foo: 100 },
      {
        events: {
          BAR: () => ({})
        }
      }
    );
    
    model.createMachine({
      // `ctx` was of type `any`
      entry: ctx => {},
      exit: assign({
        // `ctx` was of type `unknown`
        foo: ctx => 42
      })
    });

Don't miss a new xstate release

NewReleases is sending notifications on new releases.