Skip to content

xstate@5.0.0-beta.23

Pre-release
Pre-release
Compare
Choose a tag to compare
@github-actions github-actions released this 22 Aug 16:13
· 401 commits to main since this release
8163d19

Minor Changes

  • #4180 6b1646ba8 Thanks @davidkpiano! - You can now specify action types for machines:

    createMachine({
      types: {} as {
        actions: { type: 'greet'; params: { name: string } };
      },
      entry: [
        {
          type: 'greet',
          params: {
            name: 'David'
          }
        },
        // @ts-expect-error
        { type: 'greet' },
        // @ts-expect-error
        { type: 'unknownAction' }
      ]
      // ...
    });
  • #4179 2b7548579 Thanks @davidkpiano! - Output types can now be specified in the machine:

    const machine = createMachine({
      types: {} as {
        output: {
          result: 'pass' | 'fail';
          score: number;
        };
      }
      // ...
    });
    
    const actor = createActor(machine);
    
    // ...
    
    const snapshot = actor.getSnapshot();
    
    if (snapshot.output) {
      snapshot.output.result;
      // strongly typed as 'pass' | 'fail'
      snapshot.output.score;
      // strongly typed as number
    }