File tree Expand file tree Collapse file tree 2 files changed +96
-14
lines changed
Expand file tree Collapse file tree 2 files changed +96
-14
lines changed Original file line number Diff line number Diff line change @@ -765,17 +765,82 @@ export type InvokeConfig<
765765 TMeta extends MetaObject
766766> =
767767 IsLiteralString < TActor [ 'src' ] > extends true
768- ? DistributeActors <
769- TContext ,
770- TEvent ,
771- TActor ,
772- TAction ,
773- TGuard ,
774- TDelay ,
775- TEmitted ,
776- TMeta ,
777- TActor
778- >
768+ ?
769+ | DistributeActors <
770+ TContext ,
771+ TEvent ,
772+ TActor ,
773+ TAction ,
774+ TGuard ,
775+ TDelay ,
776+ TEmitted ,
777+ TMeta ,
778+ TActor
779+ >
780+ | {
781+ id ?: never ;
782+
783+ systemId ?: string ;
784+ src : AnyActorLogic ;
785+
786+ input ?:
787+ | Mapper < TContext , TEvent , NonReducibleUnknown , TEvent >
788+ | NonReducibleUnknown ;
789+ /**
790+ * The transition to take upon the invoked child machine reaching
791+ * its final top-level state.
792+ */
793+ onDone ?:
794+ | string
795+ | SingleOrArray <
796+ TransitionConfigOrTarget <
797+ TContext ,
798+ DoneActorEvent < any > , // TODO: consider replacing with `unknown`
799+ TEvent ,
800+ TActor ,
801+ TAction ,
802+ TGuard ,
803+ TDelay ,
804+ TEmitted ,
805+ TMeta
806+ >
807+ > ;
808+ /**
809+ * The transition to take upon the invoked child machine sending an
810+ * error event.
811+ */
812+ onError ?:
813+ | string
814+ | SingleOrArray <
815+ TransitionConfigOrTarget <
816+ TContext ,
817+ ErrorActorEvent ,
818+ TEvent ,
819+ TActor ,
820+ TAction ,
821+ TGuard ,
822+ TDelay ,
823+ TEmitted ,
824+ TMeta
825+ >
826+ > ;
827+
828+ onSnapshot ?:
829+ | string
830+ | SingleOrArray <
831+ TransitionConfigOrTarget <
832+ TContext ,
833+ SnapshotEvent ,
834+ TEvent ,
835+ TActor ,
836+ TAction ,
837+ TGuard ,
838+ TDelay ,
839+ TEmitted ,
840+ TMeta
841+ >
842+ > ;
843+ }
779844 : {
780845 /**
781846 * The unique identifier for the invoked machine. If not specified, this
Original file line number Diff line number Diff line change 99 emit ,
1010 enqueueActions ,
1111 EventFrom ,
12+ fromCallback ,
1213 fromPromise ,
1314 fromTransition ,
1415 log ,
@@ -492,8 +493,11 @@ describe('setup()', () => {
492493 } ) ;
493494 } ) ;
494495
495- it ( 'should not accept an `assign` with a spawner that tries to spawn an unknown actor when actors are not configured' , ( ) => {
496+ it ( 'should not accept an `assign` with a spawner that tries to spawn an unknown actor when actors are configured' , ( ) => {
496497 setup ( {
498+ actors : {
499+ foo : fromPromise ( async ( ) => { } )
500+ } ,
497501 actions : {
498502 spawnFetcher : assign ( ( { spawn } ) => {
499503 return {
@@ -506,10 +510,10 @@ describe('setup()', () => {
506510 } ) ;
507511 } ) ;
508512
509- it ( 'should not accept an invoke that tries to invoke an unknown actor when actors are not configured' , ( ) => {
513+ it ( 'should accept an invoke that tries to invoke an unknown actor when actors are not configured' , ( ) => {
510514 setup ( { } ) . createMachine ( {
515+ // @ts -expect-error
511516 invoke : {
512- // @ts -expect-error
513517 src : 'unknown'
514518 }
515519 } ) ;
@@ -2397,4 +2401,17 @@ describe('setup()', () => {
23972401
23982402 ( ( _accept : ContextFrom < typeof machine > ) => { } ) ( { myVar : 'whatever' } ) ;
23992403 } ) ;
2404+
2405+ it ( 'should accept an invoke that tries to invoke an inline actor when actors are not configured' , ( ) => {
2406+ setup ( { } ) . createMachine ( {
2407+ states : {
2408+ //...
2409+ exampleState : {
2410+ invoke : {
2411+ src : fromCallback ( ( ) => { } )
2412+ }
2413+ }
2414+ }
2415+ } ) ;
2416+ } ) ;
24002417} ) ;
You can’t perform that action at this time.
0 commit comments