Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Syth-1
Copy link

@Syth-1 Syth-1 commented Mar 4, 2025

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.

Copy link

changeset-bot bot commented Mar 4, 2025

🦋 Changeset detected

Latest commit: 16d17da

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

@davidkpiano davidkpiano requested a review from Andarist March 4, 2025 15:01
@Andarist
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants