-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Required input for spawn
when defined inside referenced actor
#5139
Required input for spawn
when defined inside referenced actor
#5139
Conversation
🦋 Changeset detectedLatest commit: 9ea95dc The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
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 |
@@ -123,5 +138,5 @@ export function createSpawner( | |||
actorRef.start(); | |||
}); | |||
return actorRef; | |||
}; | |||
}) as Spawner<any>; |
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.
The return type errors without this bypass. I think this is expected given that typescript has not enough information to correctly type-check all possible configurations.
All tests are passing, so I think it shouldn’t be an issue (the update is mostly on the types).
import { ActorRefFrom, assign, createMachine } from '../src'; | ||
|
||
describe('spawn inside machine', () => { | ||
it('input is required when defined in actor', () => { |
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.
we don't really check that it's required here, u just pass an input as an argument but the same test would pass without the patch introduced by this PR
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.
Should this be inverted with a @ts-expect-error
instead? Or is there another better way to test types?
Similar to #5055, this PR makes
input
required when usingspawn
and theinput
type in the referenced actor is defined.This prevents issues when forgetting to pass an input when using
spawn
(causing runtime errors).