-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fixed an issue with inline functions in the config object used as transition actions not having their argument types inferred #3228
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
Conversation
…nsition actions not having their argument types inferred
🦋 Changeset detectedLatest commit: 85c8e6f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
CodeSee Review Map:Review in an interactive map View more CodeSee Maps Legend |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 85c8e6f:
|
| on: { | ||
| EVENT_WITH_FLAG: { | ||
| actions: (_context, event) => { | ||
| ((_accept: 'EVENT_WITH_FLAG') => {})(event.type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty clever!
…nsition actions not having their argument types inferred (statelyai#3228) * Added a failing test for inference with inline actions * Fixed an issue with inline functions in the config object used as transition actions not having their argument types inferred * Fix small type errors * Try a solution based on merging the mapped type Co-authored-by: Matt Pocock <mattpocockvoice@gmail.com>

fixes #3217
TS minimal repro
Minimal repro fixed with Compute
The problem is in the fact that we are using an intersection here and TS doesn't the contextual type for a function in such a situation. I'm working a on a fix for this in the TypeScript itself, here, but until that lands... we must avoid an intersection here and by using
Computewe make the type at this position to be computed earlier and thus TS can treat it an object type when needed.EDIT:// actually...
Compute-based solution caused our CI to got out of memory, so I've simplified the fix and just "merged" the intersection manually, into a single mapped type