xstate
xstate copied to clipboard
[core] "Extra" generic for actions, guards, etc.
This PR adds TExtra, first introduced in #2779. Separating this out so that we can implement model.withActions() and model.withGuards(), as well as future ideas for making machine implementations more type-safe.
const model = createModel({ foo: 'string' }).withActions<
{ type: 'doThis'; greet: string } | { type: 'doThat' }
>();
model.createMachine(
{},
{
actions: {
doThis: () => {
/* ... */
},
doThat: () => {
/* ... */
},
// @ts-expect-error
unspecified: () => {
/* ... */
}
}
}
);
⚠️ No Changeset found
Latest commit: b7c90df4a701dc8f93823ddd63dbbc4176b3e2b5
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
This was somewhat superseded by all of the TAction, TGuard etc work. The model API is also not something that we have in v5.
