TS2345: PgTableWithColumns<…> from buildable shared-lib not assignable to PgTable<TableConfig>

I’m working in an Nx monorepo with a shared-lib and a Node.js API. Both use Drizzle-ORM (same version), but my API imports tables from the shared-lib. When I try to join one of those tables, TypeScript complains about a type mismatch.

error TS2345: Argument of type 
  'PgTableWithColumns<...>' 
is not assignable to parameter of type 
  'SQL<unknown> | Subquery<string, Record<string, unknown>> |
   PgViewBase<string, boolean, ColumnsSelection> |
   PgTable<TableConfig>'.

  Type 'PgTableWithColumns<...>' is not assignable to type 'PgTable<TableConfig>'.
    The types of '_.config.columns' are incompatible between these types.
      Type '{ id: PgColumn<...>; title: PgColumn<...>; /* … */ }'
      is not assignable to type
      'Record<string, PgColumn<ColumnBaseConfig<…, string>, {}, {}>>'.


import { eq } from 'drizzle-orm';
import {
  mealPlanItemsTable,
  recipeCategoriesTable,
  recipesTable,
} from '@myorg/shared-lib';

export async function getOverview(userId: string) {
  return db
    .select({ /* … */ })
    .from(mealPlanItemsTable)
    .innerJoin(
      recipeCategoriesTable,
      eq(mealPlanItemsTable.categoryId, recipeCategoriesTable.id)
    )
    .leftJoin(
      recipesTable,                // ← TS2345 triggers here
      eq(mealPlanItemsTable.recipeId, recipesTable.id)
    )
    .where(eq(mealPlanItemsTable.userId, userId));
}


Why does TypeScript see a PgTableWithColumns<> from my shared-lib as different from the PgTable<TableConfig> expected by .leftJoin, even though both come from the same Drizzle-ORM package? How can I fix this so shared-lib tables join cleanly in my API?

"drizzle-kit": "^0.31.1",
"drizzle-orm": "^0.44.0",
"drizzle-seed": "^0.3.1",
"drizzle-zod": "^0.8.2",
"zod": "^3.25.42"

I'm using zod/v4 everywhere.
Was this page helpful?