fix(types): flatten tRPC Zod schema types to resolve TS2589 inference depth errors

Cast Zod schemas with .refine()/.superRefine() to z.ZodType<InferredType> at the
procedure level. This short-circuits TypeScript's deep type recursion through
tRPC's middleware chain, eliminating 4 of 5 @ts-expect-error TS2589 suppressions
in web components (VacationModal, ProjectModal, UsersClient, CountriesClient).

Applied same pattern to allocation, timeline, staffing, dashboard, project, and
resource query/mutation procedures to reduce client-side type depth.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-10 15:28:12 +02:00
parent 0d79f97d7a
commit 9bd3781c03
21 changed files with 460 additions and 304 deletions
+12 -7
View File
@@ -4,13 +4,19 @@ import { z } from "zod";
import { CursorInputSchema, paginateCursor } from "../db/pagination.js";
import { controllerProcedure } from "../trpc.js";
const ListWithCostsInputSchema = CursorInputSchema.extend({
status: z.nativeEnum(ProjectStatus).optional(),
search: z.string().optional(),
});
export const projectCostReadProcedures = {
listWithCosts: controllerProcedure
.input(
CursorInputSchema.extend({
status: z.nativeEnum(ProjectStatus).optional(),
search: z.string().optional(),
}),
ListWithCostsInputSchema as z.ZodType<
z.infer<typeof ListWithCostsInputSchema>,
z.ZodTypeDef,
z.input<typeof ListWithCostsInputSchema>
>,
)
.query(async ({ ctx, input }) => {
const { status, search, cursor } = input;
@@ -58,9 +64,8 @@ export const projectCostReadProcedures = {
totalCostCents += booking.dailyCostCents * days;
totalPersonDays += (booking.hoursPerDay * days) / 8;
}
const utilizationPercent = project.budgetCents > 0
? Math.round((totalCostCents / project.budgetCents) * 100)
: 0;
const utilizationPercent =
project.budgetCents > 0 ? Math.round((totalCostCents / project.budgetCents) * 100) : 0;
return {
...project,
totalCostCents: Math.round(totalCostCents),