xstate icon indicating copy to clipboard operation
xstate copied to clipboard

infered typehint for state machine properties 'on' and 'initial'

Open Syth-1 opened this issue 10 months ago • 2 comments

Added a new flag 'scriptType' to state machine which provides different levels of typehint for states 'initial' and 'on' properties.

strictType can be:

  • "strict" : add type-hints and errors if types do not match, this will break some features eg spreading vars into the machine,
  • "loose" : adds type-hint but does not give errors when keys dont exist, as far as i know this keeps all compatibility,
  • undefined : no type-hint, the default behaviour if you do not provide a strictType param

I wasn't too sure how states inside states should work, so i made it scoped to the nested state you are currently on.

Syth-1 avatar Mar 04 '25 14:03 Syth-1

🦋 Changeset detected

Latest commit: 16d17da997af6feff1904768ef557f3ec1dd00bb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
xstate Minor
@xstate/graph Major
@xstate/react Major
@xstate/solid Major
@xstate/svelte Major
@xstate/vue Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Mar 04 '25 14:03 changeset-bot[bot]

Could you write down (with examples) what works and what doesn't with this? Which APIs have you considered? From what I can tell, at the very least, this forbids usage of deep patterns and IDs

Andarist avatar Mar 15 '25 14:03 Andarist