@@ -59,7 +59,7 @@ export function getRulesEffectsProcessor(
5959
6060 function createErrorDetectionEffect (
6161 effect : ProgramRuleEffect ,
62- type : keyof typeof effectActions ) : any {
62+ type : typeof effectActions [ keyof typeof effectActions ] ) : any {
6363 const result = createEffectsForConfiguredDataTypes ( effect , ( ) : any => ( {
6464 type,
6565 message : `${ effect . displayContent || '' } ${ sanitiseFalsy ( effect . data ) } ` ,
@@ -72,7 +72,7 @@ export function getRulesEffectsProcessor(
7272
7373 function createWarningEffect (
7474 effect : ProgramRuleEffect ,
75- type : keyof typeof effectActions ) : WarningEffect {
75+ type : typeof effectActions [ keyof typeof effectActions ] ) : WarningEffect {
7676 const result = createErrorDetectionEffect ( effect , type ) ;
7777 if ( Array . isArray ( result ) ) {
7878 return result ;
@@ -86,7 +86,7 @@ export function getRulesEffectsProcessor(
8686
8787 function createErrorEffect (
8888 effect : ProgramRuleEffect ,
89- type : keyof typeof effectActions ) : ErrorEffect {
89+ type : typeof effectActions [ keyof typeof effectActions ] ) : ErrorEffect {
9090 const result = createErrorDetectionEffect ( effect , type ) ;
9191 if ( Array . isArray ( result ) ) {
9292 return result ;
@@ -102,7 +102,6 @@ export function getRulesEffectsProcessor(
102102 let outputValue ;
103103 if ( normalizedValue || normalizedValue === 0 || normalizedValue === false ) {
104104 const converterName : string = mapTypeToInterfaceFnName [ valueType ] ;
105- // $FlowExpectedError
106105 const outputConverter = outputConverters [ converterName ] ;
107106 if ( ! converterName || ! outputConverter ) {
108107 log . warn ( errorCreator ( 'converter for valueType is missing' ) ( { valueType } ) ) ;
@@ -118,7 +117,7 @@ export function getRulesEffectsProcessor(
118117 function createAssignValueEffect (
119118 effect : ProgramRuleEffect ,
120119 element : DataElement | TrackedEntityAttribute ,
121- targetDataType : keyof typeof rulesEngineEffectTargetDataTypes ,
120+ targetDataType : typeof rulesEngineEffectTargetDataTypes [ keyof typeof rulesEngineEffectTargetDataTypes ] ,
122121 ) : AssignOutputEffect {
123122 const normalizedValue = normalizeRuleVariable ( effect . data , element . valueType ) ;
124123 const outputValue = convertNormalizedValueToOutputValue ( normalizedValue , element . valueType ) ;
@@ -140,7 +139,7 @@ export function getRulesEffectsProcessor(
140139 effects . push ( createAssignValueEffect (
141140 effect ,
142141 dataElements [ effect . dataElementId ] ,
143- 'DATA_ELEMENT' as keyof typeof rulesEngineEffectTargetDataTypes ) ,
142+ rulesEngineEffectTargetDataTypes . DATA_ELEMENT ) ,
144143 ) ;
145144 }
146145 if ( trackedEntityAttributes &&
@@ -149,7 +148,7 @@ export function getRulesEffectsProcessor(
149148 effects . push ( createAssignValueEffect (
150149 effect ,
151150 trackedEntityAttributes [ effect . trackedEntityAttributeId ] ,
152- 'TRACKED_ENTITY_ATTRIBUTE' as keyof typeof rulesEngineEffectTargetDataTypes ) ,
151+ rulesEngineEffectTargetDataTypes . TRACKED_ENTITY_ATTRIBUTE ) ,
153152 ) ;
154153 }
155154 return effects ;
@@ -160,7 +159,7 @@ export function getRulesEffectsProcessor(
160159 dataElements : DataElements | null ,
161160 trackedEntityAttributes : TrackedEntityAttributes | null ,
162161 formValues ?: { [ key : string ] : any } | null ,
163- onProcessValue ?: ( value : any , type : keyof typeof typeKeys ) => any ,
162+ onProcessValue ?: ( value : any , type : typeof typeKeys [ keyof typeof typeKeys ] ) => any ,
164163 ) : Array < HideOutputEffect > {
165164 const outputEffects = createEffectsForConfiguredDataTypes (
166165 effect ,
@@ -169,32 +168,31 @@ export function getRulesEffectsProcessor(
169168 content : effect . content ,
170169 } ) ,
171170 ) ;
172- const result = getOutputEffectsWithPreviousValueCheck ( {
171+ return getOutputEffectsWithPreviousValueCheck ( {
173172 outputEffects,
174173 formValues,
175- dataElementId : effect . dataElementId ,
176- trackedEntityAttributeId : effect . trackedEntityAttributeId ,
174+ dataElementId : effect . dataElementId as string ,
175+ trackedEntityAttributeId : effect . trackedEntityAttributeId as string ,
177176 dataElements,
178177 trackedEntityAttributes,
179178 onProcessValue,
180179 } ) ;
181- return Array . isArray ( result ) ? result : [ result as any ] ;
182180 }
183181
184182 function processShowError ( effect : ProgramRuleEffect ) : ErrorEffect {
185- return createErrorEffect ( effect , effectActions . SHOW_ERROR as any ) ;
183+ return createErrorEffect ( effect , effectActions . SHOW_ERROR ) ;
186184 }
187185
188186 function processShowWarning ( effect : ProgramRuleEffect ) : WarningEffect {
189- return createWarningEffect ( effect , effectActions . SHOW_WARNING as any ) ;
187+ return createWarningEffect ( effect , effectActions . SHOW_WARNING ) ;
190188 }
191189
192190 function processShowErrorOnComplete ( effect : ProgramRuleEffect ) : ErrorEffect {
193- return createErrorEffect ( effect , effectActions . SHOW_ERROR_ONCOMPLETE as any ) ;
191+ return createErrorEffect ( effect , effectActions . SHOW_ERROR_ONCOMPLETE ) ;
194192 }
195193
196194 function processShowWarningOnComplete ( effect : ProgramRuleEffect ) : WarningEffect {
197- return createWarningEffect ( effect , effectActions . SHOW_WARNING_ONCOMPLETE as any ) ;
195+ return createWarningEffect ( effect , effectActions . SHOW_WARNING_ONCOMPLETE ) ;
198196 }
199197
200198 function processHideSection ( effect : ProgramRuleEffect ) : HideOutputEffect | null {
@@ -203,7 +201,7 @@ export function getRulesEffectsProcessor(
203201 }
204202
205203 return {
206- type : effectActions . HIDE_SECTION as any ,
204+ type : effectActions . HIDE_SECTION ,
207205 id : effect . programStageSectionId ,
208206 } ;
209207 }
@@ -214,21 +212,21 @@ export function getRulesEffectsProcessor(
214212 }
215213
216214 return {
217- type : effectActions . HIDE_PROGRAM_STAGE as any ,
215+ type : effectActions . HIDE_PROGRAM_STAGE ,
218216 id : effect . programStageId ,
219217 } ;
220218 }
221219
222220 function processMakeCompulsory ( effect : ProgramRuleEffect ) : Array < CompulsoryEffect > {
223221 return createEffectsForConfiguredDataTypes ( effect , ( ) => ( {
224- type : effectActions . MAKE_COMPULSORY as any ,
222+ type : effectActions . MAKE_COMPULSORY ,
225223 } ) ) ;
226224 }
227225
228226 function processDisplayText ( effect : ProgramRuleEffect ) : any {
229227 const message = effect . displayContent || '' ;
230228 return {
231- type : effectActions . DISPLAY_TEXT as any ,
229+ type : effectActions . DISPLAY_TEXT ,
232230 id : effect . location ,
233231 displayText : {
234232 id : effect . id ,
@@ -242,7 +240,7 @@ export function getRulesEffectsProcessor(
242240 const data = effect . data !== undefined ? effect . data : '' ;
243241
244242 return {
245- type : effectActions . DISPLAY_KEY_VALUE_PAIR as any ,
243+ type : effectActions . DISPLAY_KEY_VALUE_PAIR ,
246244 id : effect . location ,
247245 displayKeyValuePair : {
248246 id : effect . id ,
@@ -255,21 +253,21 @@ export function getRulesEffectsProcessor(
255253
256254 function processHideOptionGroup ( effect : ProgramRuleEffect ) : any {
257255 return createEffectsForConfiguredDataTypes ( effect , ( ) => ( {
258- type : effectActions . HIDE_OPTION_GROUP as any ,
256+ type : effectActions . HIDE_OPTION_GROUP ,
259257 optionGroupId : effect . optionGroupId ,
260258 } ) ) ;
261259 }
262260
263261 function processHideOption ( effect : ProgramRuleEffect ) : any {
264262 return createEffectsForConfiguredDataTypes ( effect , ( ) => ( {
265- type : effectActions . HIDE_OPTION as any ,
263+ type : effectActions . HIDE_OPTION ,
266264 optionId : effect . optionId ,
267265 } ) ) ;
268266 }
269267
270268 function processShowOptionGroup ( effect : ProgramRuleEffect ) : any {
271269 return createEffectsForConfiguredDataTypes ( effect , ( ) => ( {
272- type : effectActions . SHOW_OPTION_GROUP as any ,
270+ type : effectActions . SHOW_OPTION_GROUP ,
273271 optionGroupId : effect . optionGroupId ,
274272 } ) ) ;
275273 }
@@ -300,9 +298,9 @@ export function getRulesEffectsProcessor(
300298 } : {
301299 effects : Array < ProgramRuleEffect > ,
302300 dataElements : DataElements | null ,
303- trackedEntityAttributes : TrackedEntityAttributes | null ,
301+ trackedEntityAttributes ? : TrackedEntityAttributes | null ,
304302 formValues ?: { [ key : string ] : any } | null ,
305- onProcessValue ?: ( value : any , type : keyof typeof typeKeys ) => any ,
303+ onProcessValue ?: ( value : any , type : typeof typeKeys [ keyof typeof typeKeys ] ) => any ,
306304 } ) : OutputEffects {
307305 return effects
308306 . filter ( ( { action } ) => mapActionsToProcessor [ action ] )
0 commit comments