File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,12 +108,14 @@ neuron.registerParameter(StateNumberParameter.TYPE, StateNumberParameter);
108108neuron . registerAction ( SetDecisionAction . TYPE , SetDecisionAction ) ;
109109
110110const result = new Synapse ( neuron ) . execute ( script , input as ExecutionContext ) ;
111- const eligibility = result . context . state . eligibility as { eligible ?: boolean ; decision ?: string } ;
111+ const eligibility = result . context . state . eligibility as
112+ | { eligible ?: boolean ; decision ?: string }
113+ | undefined ;
112114const actual = {
113115 ok : result . isSuccessful ( ) ,
114116 rulesExecuted : result . value ,
115- eligible : eligibility . eligible ,
116- decision : eligibility . decision ,
117+ eligible : eligibility ? .eligible ,
118+ decision : eligibility ? .decision ,
117119 messages : result . context . messages . map ( ( message ) => message . text ) ,
118120} ;
119121
Original file line number Diff line number Diff line change @@ -116,12 +116,14 @@ neuron.registerParameter(StateNumberParameter.TYPE, StateNumberParameter);
116116neuron . registerAction ( ApplyDiscountAction . TYPE , ApplyDiscountAction ) ;
117117
118118const result = new Synapse ( neuron ) . execute ( script , input as ExecutionContext ) ;
119- const cart = result . context . state . cart as { finalTotal ?: number ; discountAmount ?: number } ;
119+ const cart = result . context . state . cart as
120+ | { finalTotal ?: number ; discountAmount ?: number }
121+ | undefined ;
120122const actual = {
121123 ok : result . isSuccessful ( ) ,
122124 rulesExecuted : result . value ,
123- finalTotal : cart . finalTotal ,
124- discountAmount : cart . discountAmount ,
125+ finalTotal : cart ? .finalTotal ,
126+ discountAmount : cart ? .discountAmount ,
125127 messages : result . context . messages . map ( ( message ) => message . text ) ,
126128} ;
127129
Original file line number Diff line number Diff line change @@ -110,12 +110,14 @@ neuron.registerParameter(StateNumberParameter.TYPE, StateNumberParameter);
110110neuron . registerAction ( SetRouteAction . TYPE , SetRouteAction ) ;
111111
112112const result = new Synapse ( neuron ) . execute ( script , input as ExecutionContext ) ;
113- const workflow = result . context . state . workflow as { route ?: string ; slaHours ?: number } ;
113+ const workflow = result . context . state . workflow as
114+ | { route ?: string ; slaHours ?: number }
115+ | undefined ;
114116const actual = {
115117 ok : result . isSuccessful ( ) ,
116118 rulesExecuted : result . value ,
117- route : workflow . route ,
118- slaHours : workflow . slaHours ,
119+ route : workflow ? .route ,
120+ slaHours : workflow ? .slaHours ,
119121 messages : result . context . messages . map ( ( message ) => message . text ) ,
120122} ;
121123
You can’t perform that action at this time.
0 commit comments