Skip to content
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

[core] Tighten StateMachine types and fix issue #5008 #5009

Merged

Conversation

davidkpiano
Copy link
Member

The internal types for StateMachine<...> have been improved so that all type params are required, to prevent errors when using the types. This fixes weird issues like #5008.

@davidkpiano davidkpiano linked an issue Jul 31, 2024 that may be closed by this pull request
Copy link

changeset-bot bot commented Jul 31, 2024

🦋 Changeset detected

Latest commit: 3059beb

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

This PR includes changesets to release 1 package
Name Type
xstate 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

@@ -413,33 +413,33 @@ describe('state tests', () => {
});

it('should test with input', () => {
const model = createTestModel(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a little weird too... for some reason, TS complained if setup(…) was inside createTestModel(setup(…).createMachine(…)) but not if I moved it outside.

Comment on lines -69 to +71
TEmitted extends EventObject = EventObject, // TODO: remove default
TMeta extends MetaObject = MetaObject,
TConfig extends StateSchema = StateSchema
TEmitted extends EventObject,
TMeta extends MetaObject,
TConfig extends StateSchema
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main change. By having these as optional, we were (well, at least I was) miscounting the generic type params, and some were erroneously using their default types.

@davidkpiano davidkpiano merged commit 51d4c4f into main Jul 31, 2024
1 check passed
@davidkpiano davidkpiano deleted the davidkpiano/5008-bug-5170-property-machine-is-missing-in-type branch July 31, 2024 14:36
@github-actions github-actions bot mentioned this pull request Jul 31, 2024
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.

Bug: 5.17.0 Property "(machine)" is missing in type...
1 participant