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
+14 -3
View File
@@ -1,3 +1,4 @@
import type { z } from "zod";
import { createTRPCRouter, controllerProcedure } from "../trpc.js";
import {
dashboardChargeabilityOverviewInputSchema,
@@ -34,7 +35,13 @@ export const dashboardRouter = createTRPCRouter({
.query(({ ctx, input }) => getDashboardTopValueResourcesRead(ctx, input)),
getDemand: controllerProcedure
.input(dashboardDemandInputSchema)
.input(
dashboardDemandInputSchema as z.ZodType<
z.infer<typeof dashboardDemandInputSchema>,
z.ZodTypeDef,
z.input<typeof dashboardDemandInputSchema>
>,
)
.query(({ ctx, input }) => getDashboardDemandRead(ctx, input)),
getDetail: controllerProcedure
@@ -47,7 +54,9 @@ export const dashboardRouter = createTRPCRouter({
getBudgetForecast: controllerProcedure.query(({ ctx }) => getDashboardBudgetForecastRead(ctx)),
getBudgetForecastDetail: controllerProcedure.query(({ ctx }) => getDashboardBudgetForecastDetail(ctx)),
getBudgetForecastDetail: controllerProcedure.query(({ ctx }) =>
getDashboardBudgetForecastDetail(ctx),
),
getSkillGaps: controllerProcedure.query(({ ctx }) => getDashboardSkillGapsRead(ctx)),
@@ -55,5 +64,7 @@ export const dashboardRouter = createTRPCRouter({
getProjectHealth: controllerProcedure.query(({ ctx }) => getDashboardProjectHealthRead(ctx)),
getProjectHealthDetail: controllerProcedure.query(({ ctx }) => getDashboardProjectHealthDetail(ctx)),
getProjectHealthDetail: controllerProcedure.query(({ ctx }) =>
getDashboardProjectHealthDetail(ctx),
),
});