Skip to content

[@xstate/store] Fix TS error localization #5347

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

Merged
merged 5 commits into from
Aug 4, 2025

Conversation

davidkpiano
Copy link
Member

Fix TS error localization in createStore(…) overloads

Previously, TS errors in transitions would appear on the createStore call itself rather than on the specific transition. This was caused by the 3rd overload (for StoreLogic) interfering with overload resolution.

    createStore({
      context: {
        sort: 'asc' as const
      },
      on: {
        // (error would appear on createStore, not here!)
        // @ts-expect-error
        changeSort: (_, event: { sort: 'desc' }) => ({
          sort: event.sort
        })
      }
    });

Copy link

changeset-bot bot commented Aug 3, 2025

🦋 Changeset detected

Latest commit: 5df669c

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

@davidkpiano davidkpiano requested a review from Andarist August 3, 2025 15:05
davidkpiano and others added 2 commits August 4, 2025 07:31
@davidkpiano davidkpiano merged commit 4dff4e9 into main Aug 4, 2025
1 check passed
@davidkpiano davidkpiano deleted the davidkpiano/xstate-store-ts-narrowing-error branch August 4, 2025 11:32
@github-actions github-actions bot mentioned this pull request Aug 4, 2025
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