@@ -69,7 +69,7 @@ export interface IActionNode<State, Props> extends IWithNodeState {
69
69
id : string
70
70
name : string
71
71
type : NodeType . Action
72
- fn : ( state : Draft < State > , props : Props ) => void | Promise < void >
72
+ fn : ( state : State , props : Props ) => void | Promise < void >
73
73
parent ?: IAnyNode < State , Props >
74
74
}
75
75
export interface IStateNode < State , Props > extends IWithNodeState {
@@ -92,19 +92,19 @@ export interface ISequenceNode<State, Props> extends IWithNodeState {
92
92
id : string
93
93
type : NodeType . Sequence
94
94
parent ?: IAnyNode < State , Props >
95
- children : Array < ICompositeNode < State , Props > | ILeafNode < State , Props > >
95
+ children : IAnyChildNode < State , Props > [ ]
96
96
}
97
97
export interface IParallelNode < State , Props > extends IWithNodeState {
98
98
id : string
99
99
type : NodeType . Parallel
100
100
parent ?: IAnyNode < State , Props >
101
- children : Array < ICompositeNode < State , Props > | IActionNode < State , Props > >
101
+ children : IAnyChildNode < State , Props > [ ]
102
102
}
103
103
export interface ISelectorNode < State , Props > extends IWithNodeState {
104
104
id : string
105
105
type : NodeType . Selector
106
106
parent ?: IAnyNode < State , Props >
107
- children : Array < ICompositeNode < State , Props > | IActionNode < State , Props > >
107
+ children : IAnyChildNode < State , Props > [ ]
108
108
}
109
109
export interface IDecoratorNode < State , Props > extends IWithNodeState {
110
110
id : string
@@ -147,7 +147,6 @@ export interface IWithNodeState {
147
147
*/
148
148
setValue : ( key : string , value : any ) => any
149
149
}
150
-
151
150
export type IOptions < Props > = {
152
151
props ?: Props
153
152
setState : any
@@ -226,7 +225,7 @@ export const nodes = {
226
225
* Runs child nodes in sequence until it finds one that succeeds. Succeeds when it finds the first child that succeeds. For child nodes that fail, it moves forward to the next child node. While a child is running it stays on that child node without moving forward.
227
226
*/
228
227
selector : function < State , Props > (
229
- children : Array < ICompositeNode < State , Props > | IActionNode < State , Props > >
228
+ children : IAnyChildNode < State , Props > [ ]
230
229
) : ISelectorNode < State , Props > {
231
230
return {
232
231
id : nanoid ( ) ,
@@ -239,7 +238,7 @@ export const nodes = {
239
238
* Runs each child node one by one. Fails for the first child node that fails. Moves to the next child when the current running child succeeds. Stays on the current child node while it returns running. Succeeds when all child nodes have succeeded.
240
239
*/
241
240
sequence : function < State , Props > (
242
- children : Array < ICompositeNode < State , Props > | ILeafNode < State , Props > >
241
+ children : IAnyChildNode < State , Props > [ ]
243
242
) : ISequenceNode < State , Props > {
244
243
return {
245
244
id : nanoid ( ) ,
@@ -254,7 +253,7 @@ export const nodes = {
254
253
* Runs all child nodes in parallel. Continues to run until a required number of child nodes have either failed or succeeded.
255
254
*/
256
255
parallel : function < State , Props > (
257
- children : Array < ICompositeNode < State , Props > | IActionNode < State , Props > >
256
+ children : IAnyChildNode < State , Props > [ ]
258
257
) : IParallelNode < State , Props > {
259
258
return {
260
259
id : nanoid ( ) ,
@@ -265,7 +264,7 @@ export const nodes = {
265
264
} ,
266
265
condition : function < State , Props > (
267
266
name : string ,
268
- fn ?: ( state : State , props : Props ) => void
267
+ fn ?: ( state : State , props : Props ) => any
269
268
) : IConditionNode < State , Props > {
270
269
return {
271
270
id : nanoid ( ) ,
@@ -327,7 +326,7 @@ export const nodes = {
327
326
} ,
328
327
action : function < State , Props > (
329
328
name : string ,
330
- fn : ( state : Draft < State > , props : Props ) => void
329
+ fn : ( state : State , props : Props ) => void
331
330
) : IActionNode < State , Props > {
332
331
return {
333
332
id : nanoid ( ) ,
@@ -432,7 +431,7 @@ function _interpret<State, Props>(
432
431
433
432
const nextState = produce (
434
433
state ,
435
- draft => node . fn ( draft , options . props || ( { } as Props ) ) ,
434
+ draft => node . fn ( draft as State , options . props || ( { } as Props ) ) ,
436
435
patches => {
437
436
node . setValue ( _StoreKey . Patches , patches )
438
437
0 commit comments