diff --git a/app/soapbox/schemas/utils.ts b/app/soapbox/schemas/utils.ts index d0bc4cc8f8..72f5f49d9b 100644 --- a/app/soapbox/schemas/utils.ts +++ b/app/soapbox/schemas/utils.ts @@ -4,10 +4,13 @@ import type { CustomEmoji } from './custom-emoji'; /** Validates individual items in an array, dropping any that aren't valid. */ function filteredArray(schema: T) { - return z.any().array().transform((arr) => ( - arr.map((item) => schema.safeParse(item).success ? item as z.infer : undefined) - .filter((item): item is z.infer => Boolean(item)) - )); + return z.any().array() + .transform((arr) => ( + arr.map((item) => { + const parsed = schema.safeParse(item); + return parsed.success ? parsed.data : undefined; + }).filter((item): item is z.infer => Boolean(item)) + )); } /** Map a list of CustomEmoji to their shortcodes. */