From 89b1f4edaa9329c0ad52ef25f7a409c4465e7cd2 Mon Sep 17 00:00:00 2001 From: Ola Pawlus Date: Mon, 1 Dec 2025 14:27:19 +0100 Subject: [PATCH] [Stack Alerts] Resolve TS expect error after TypeScript upgrade by validating string array --- .../rule_types/geo_containment/rule_form/rule_form.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/x-pack/platform/plugins/shared/stack_alerts/public/rule_types/geo_containment/rule_form/rule_form.tsx b/x-pack/platform/plugins/shared/stack_alerts/public/rule_types/geo_containment/rule_form/rule_form.tsx index 2e96992569c9d..e427de76d6539 100644 --- a/x-pack/platform/plugins/shared/stack_alerts/public/rule_types/geo_containment/rule_form/rule_form.tsx +++ b/x-pack/platform/plugins/shared/stack_alerts/public/rule_types/geo_containment/rule_form/rule_form.tsx @@ -17,10 +17,11 @@ export const RuleForm: React.FunctionComponent< RuleTypeParamsExpressionProps > = (props) => { function getValidationError(key: string) { - // @ts-expect-error upgrade typescript v5.1.6 - return props.errors[key]?.length > 0 && key in props.ruleParams - ? (props.errors[key] as string[])[0] - : null; + const error = props.errors[key]; + if (Array.isArray(error) && error.length > 0 && key in props.ruleParams) { + return typeof error[0] === 'string' ? error[0] : null; + } + return null; } return (