Fixed an issue with inline functions in the config object used as transition actions not having their argument types inferred#3228
Merged
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:
|
davidkpiano
reviewed
Apr 16, 2022
| on: { | ||
| EVENT_WITH_FLAG: { | ||
| actions: (_context, event) => { | ||
| ((_accept: 'EVENT_WITH_FLAG') => {})(event.type); |
davidkpiano
approved these changes
Apr 16, 2022
Merged
nevilm-lt
pushed a commit
to nevilm-lt/xstate
that referenced
this pull request
Apr 22, 2022
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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