Relations not building into type

Im having an issue where the relations types are not correctly being tied to the table

const todaysVisits = await db.query.visits.findMany({
    where: sql`DATE(${visits.date}) = ${date.format("YYYY-MM-DD")}`,
    with: {
      job: {
        // getting type error here but the data is fetching correctly
        where: eq(jobs.company_id, user.privateMetadata.company_id as string),
        columns: {
          instructions: true,
        },
        with: {
          property: {
            columns: {
              nick_name: true,
              address: true,
            },
            with: {
              client: {
                columns: {
                  full_name: true,
                },
              },
            },
          },
        },
      },
    },
  })


then later when trying to use the data
<span>
  // getting type any here too
  {visit.job?.property?.address ?? ""}
</span>
Was this page helpful?