Infer Types from Partial Select Prepared Statement

Hi all,

I am not sure if I am inferring the types of a partial
select
properly, below is what I am trying to do:
export const deploymentListByOrg = db
  .select({ id: deployments.id, name: deployments.name, description: deployments.description })
  .from(deployments)
  .where(eq(deployments.organizationId, sql.placeholder("orgId")))
  .prepare();
export type DeploymentListResponse = typeof deploymentListByOrg.all;
// export type DeploymentListResponse = { id: number; name: string; description: string | null }[]; <--- this is the type of the response that should be inferred

Is this the recommended way to do this? Is there a better way of inferring these types? I need to infer these types because when using this with tRPC, the frontend thinks the response is
any
unless I cast the return type with
as


This is what it's saying the types is, but I don't want to have the
Promise<>
just the actual data that is returned
image.png
Was this page helpful?