Skip to content

xstate@4.37.0

Compare
Choose a tag to compare
@github-actions github-actions released this 24 Feb 15:20
· 1411 commits to main since this release
54ec307

Minor Changes

  • #3835 431472082 Thanks @with-heart! - The new TagsFrom helper type extracts the type of tags from a state machine when typegen is enabled:

    const machine = createMachine({
      // `tags` attached to machine via typegen
      tsTypes: {} as import('./machine.typegen').Typegen0,
      tags: ['a', 'b'],
      states: {
        idle: { tags: 'c' }
      }
    });
    
    type Tags = TagsFrom<typeof machine>; // 'a' | 'b' | 'c'

    If typegen is not enabled, TagsFrom returns string:

    const machine = createMachine({
      tags: ['a', 'b'],
      states: {
        idle: { tags: 'c' }
      }
    });
    
    type Tags = TagsFrom<typeof machine>; // string

Patch Changes