Skip to content

Commit ecdd587

Browse files
olapawlusNicholasPeretti
authored andcommitted
[Stack Alerts] Resolve TS expect error after TypeScript upgrade by validating string array (elastic#244791)
Resolves partially elastic#187897
1 parent 5769113 commit ecdd587

File tree

1 file changed

+5
-4
lines changed
  • x-pack/platform/plugins/shared/stack_alerts/public/rule_types/geo_containment/rule_form

1 file changed

+5
-4
lines changed

x-pack/platform/plugins/shared/stack_alerts/public/rule_types/geo_containment/rule_form/rule_form.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ export const RuleForm: React.FunctionComponent<
1717
RuleTypeParamsExpressionProps<GeoContainmentAlertParams>
1818
> = (props) => {
1919
function getValidationError(key: string) {
20-
// @ts-expect-error upgrade typescript v5.1.6
21-
return props.errors[key]?.length > 0 && key in props.ruleParams
22-
? (props.errors[key] as string[])[0]
23-
: null;
20+
const error = props.errors[key];
21+
if (Array.isArray(error) && error.length > 0 && key in props.ruleParams) {
22+
return typeof error[0] === 'string' ? error[0] : null;
23+
}
24+
return null;
2425
}
2526

2627
return (

0 commit comments

Comments
 (0)