In route/controller code, don’t rely on repeated as casts to satisfy TypeScript—normalize/validate types once, then keep the rest of the logic strongly typed.
Apply this style rule:
(value as unknown[]).filter(...) or filteredX as never, it’s a formatting/readability smell.Example (mimic the proposed approach):
// Normalize once to the correct element shape
const normalizeChallenges = (arr: unknown) => arr as Array<{ id: string }>;
const filteredCompletedChallenges = normalizeChallenges(user.completedChallenges)
.filter(c => !challengeIdsToReset.includes(c.id));
await fastify.prisma.user.update({
where: { id: req.user!.id },
data: {
completedChallenges: filteredCompletedChallenges,
},
});
Enter the URL of a public GitHub repository