statelyai / xstate

Actor-based state management & orchestration for complex app logic.
https://stately.ai/docs
MIT License
26.51k stars 1.22k forks source link

[@xstate/store] Fix `createStoreWithProducer(…)` types #4890

Closed davidkpiano closed 1 month ago

davidkpiano commented 1 month ago

The context type for createStoreWithProducer(producer, context, transitions) will now be properly inferred.

const store = createStoreWithProducer(
  produce,
  {
    count: 0
  },
  {
    // ...
  }
);

store.getSnapshot().context;
// BEFORE: StoreContext
// NOW: { count: number }
changeset-bot[bot] commented 1 month ago

🦋 Changeset detected

Latest commit: 30bebf52a4ae66db24cfa4cb5e76fa2abed7a69a

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

This PR includes changesets to release 1 package | Name | Type | | ------------- | ----- | | @xstate/store | Patch |

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