Turborepo - no type safety when using drizzle in other modules

Hi all, I am setting up a monorepo with turborepo where I have an API under apps/api and a database module under packages/db. I am losing type safety when importing the
db
instance in another package. I export all of my tables and the drizzle instance like so below:

// packages/db/src/index.ts
import "@dotenvx/dotenvx";
import { drizzle } from "drizzle-orm/libsql";
import * as schema from "./schemas"; // barrel file to export all schemas and types

if (!process.env.DATABASE_URL) {
    throw new Error("DATABASE_URL not set");
}

export const db = drizzle({
    connection: {
        url: process.env.DATABASE_URL,
        authToken: process.env.AUTH_TOKEN,
    },
    schema,
});
export * from "drizzle-orm";
export * from "./schemas";


I am not sure if this is a problem with my tsconfig for both of these modules or how I am exporting packages.

I attached screenshots of what my IDE displays when I hover over users and what the returned value should be. Any help would be appreciated, thank you 🙏
Screenshot_2025-07-16_at_12.30.28_AM.png
Screenshot_2025-07-16_at_12.34.52_AM.png
Was this page helpful?